From 6f20d2345a20941d4700a18cc93e423a078ed824 Mon Sep 17 00:00:00 2001 From: hanna-g-sn Date: Tue, 21 Oct 2025 10:44:44 +0100 Subject: [PATCH 1/2] 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. --- .../README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Server-Side Components/Transform Map Scripts/Incident Priority Set on Insert Only/README.md diff --git a/Server-Side Components/Transform Map Scripts/Incident Priority Set on Insert Only/README.md b/Server-Side Components/Transform Map Scripts/Incident Priority Set on Insert Only/README.md new file mode 100644 index 0000000000..dec7119b2f --- /dev/null +++ b/Server-Side Components/Transform Map Scripts/Incident Priority Set on Insert Only/README.md @@ -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 From 049c24ac5a539b9ba849fd09703c6ea19cb23b2d Mon Sep 17 00:00:00 2001 From: hanna-g-sn Date: Tue, 21 Oct 2025 10:45:37 +0100 Subject: [PATCH 2/2] Add insert-only priority setting script Implement onBefore script to set priority during insert operations based on impact and urgency. --- .../onBefore_set_priority_insert_only.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Server-Side Components/Transform Map Scripts/Incident Priority Set on Insert Only/onBefore_set_priority_insert_only.js diff --git a/Server-Side Components/Transform Map Scripts/Incident Priority Set on Insert Only/onBefore_set_priority_insert_only.js b/Server-Side Components/Transform Map Scripts/Incident Priority Set on Insert Only/onBefore_set_priority_insert_only.js new file mode 100644 index 0000000000..fc0c814ff2 --- /dev/null +++ b/Server-Side Components/Transform Map Scripts/Incident Priority Set on Insert Only/onBefore_set_priority_insert_only.js @@ -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);