Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Incident priority set on insert only

## What this solves
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.

## Where to use
Attach to your Incident Transform Map as an onBefore script.

## How it works
- Checks the Transform Map action variable for insert vs update
- On insert, computes priority from impact and urgency
- On update, does nothing to priority

## References
- Transform Map scripts
https://www.servicenow.com/docs/bundle/zurich-integrate-applications/page/administer/import-sets/task/t_AddOnBeforeScriptToTransformMap.html
- Incident fields and priority logic
https://www.servicenow.com/docs/bundle/zurich-it-service-management/page/product/incident-management/concept/incident-fields.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Transform Map onBefore script: set priority on insert, not on update
(function runTransformScript(source, map, log, target) {
try {
if (String(action).toLowerCase() !== 'insert') {
log.info('Priority unchanged on update for number: ' + (target.number || '(new)'));
return;
}

var impact = Number(source.impact) || 3; // 1..3 typical
var urgency = Number(source.urgency) || 3; // 1..3 typical

// Simple matrix: priority = impact + urgency - 1, clamped 1..5
var p = Math.max(1, Math.min(5, (impact + urgency) - 1));
target.priority = String(p);
log.info('Priority set on insert to ' + p);
} catch (e) {
log.error('Insert-only priority failed: ' + e.message);
}
})(source, map, log, target);
Loading