diff --git a/Server-Side Components/Business Rules/Cascade Priority Change from Parent to Child Incidents/README.md b/Server-Side Components/Business Rules/Cascade Priority Change from Parent to Child Incidents/README.md new file mode 100644 index 0000000000..f78cedb309 --- /dev/null +++ b/Server-Side Components/Business Rules/Cascade Priority Change from Parent to Child Incidents/README.md @@ -0,0 +1 @@ +This code_snippet.js script automatically updates the priority of all child incidents whenever the parent incident’s priority is modified. diff --git a/Server-Side Components/Business Rules/Cascade Priority Change from Parent to Child Incidents/code_snippet.js b/Server-Side Components/Business Rules/Cascade Priority Change from Parent to Child Incidents/code_snippet.js new file mode 100644 index 0000000000..5ec3cc0841 --- /dev/null +++ b/Server-Side Components/Business Rules/Cascade Priority Change from Parent to Child Incidents/code_snippet.js @@ -0,0 +1,16 @@ +// Below script automatically updates the priority of all child incidents whenever the parent incident’s priority is modified. +(function executeRule(current, previous /*null when async*/ ) { + + if (current.priority != previous.priority) { + var childInc = new GlideRecord('incident'); + childInc.addQuery('parent_incident', current.sys_id); + childInc.query(); + + while (childInc.next()) { + childInc.impact = current.impact; + childInc.urgency = current.urgency; + childInc.work_notes = 'Priority updated automatically from parent incident ' + current.number; + childInc.update(); + } + } +})(current, previous);