Skip to content

Commit 049c24a

Browse files
authored
Add insert-only priority setting script
Implement onBefore script to set priority during insert operations based on impact and urgency.
1 parent 6f20d23 commit 049c24a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Transform Map onBefore script: set priority on insert, not on update
2+
(function runTransformScript(source, map, log, target) {
3+
try {
4+
if (String(action).toLowerCase() !== 'insert') {
5+
log.info('Priority unchanged on update for number: ' + (target.number || '(new)'));
6+
return;
7+
}
8+
9+
var impact = Number(source.impact) || 3; // 1..3 typical
10+
var urgency = Number(source.urgency) || 3; // 1..3 typical
11+
12+
// Simple matrix: priority = impact + urgency - 1, clamped 1..5
13+
var p = Math.max(1, Math.min(5, (impact + urgency) - 1));
14+
target.priority = String(p);
15+
log.info('Priority set on insert to ' + p);
16+
} catch (e) {
17+
log.error('Insert-only priority failed: ' + e.message);
18+
}
19+
})(source, map, log, target);

0 commit comments

Comments
 (0)