Skip to content

Commit 05b9e6a

Browse files
authored
Transform Map - Prevent Priority Update unless on Insert - Pull 1 (#2365)
* Add README for Incident Priority Set on Insert Only Added documentation for the Incident Priority Set on Insert Only script, explaining its purpose, usage, and functionality. * Add insert-only priority setting script Implement onBefore script to set priority during insert operations based on impact and urgency.
1 parent cdde65d commit 05b9e6a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Incident priority set on insert only
2+
3+
## What this solves
4+
Recurring imports often overwrite priority even after the service desk has triaged the ticket. This onBefore script sets priority only when a row is inserted. Updates pass through without touching priority.
5+
6+
## Where to use
7+
Attach to your Incident Transform Map as an onBefore script.
8+
9+
## How it works
10+
- Checks the Transform Map action variable for insert vs update
11+
- On insert, computes priority from impact and urgency
12+
- On update, does nothing to priority
13+
14+
## References
15+
- Transform Map scripts
16+
https://www.servicenow.com/docs/bundle/zurich-integrate-applications/page/administer/import-sets/task/t_AddOnBeforeScriptToTransformMap.html
17+
- Incident fields and priority logic
18+
https://www.servicenow.com/docs/bundle/zurich-it-service-management/page/product/incident-management/concept/incident-fields.html
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)