Skip to content

Commit c231ab4

Browse files
authored
Create script.js
1 parent 9f771b3 commit c231ab4

File tree

1 file changed

+15
-0
lines changed
  • Server-Side Components/Business Rules/Cancel Incomplete Playbooks on Closure

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(function executeRule(current, previous /*null when async*/) {
2+
3+
// Find associated playbooks
4+
var playbookGR = new GlideRecord('sys_pd_context');
5+
playbookGR.addQuery('input_table', 'incident');
6+
playbookGR.addQuery('input_record', current.sys_id);
7+
playbookGR.addQuery('state', 'NOT IN', 'completed,canceled');
8+
playbookGR.query();
9+
10+
// Cancel them to avoid hanging context
11+
while (playbookGR.next()) {
12+
sn_playbook.PlaybookExperience.cancelPlaybook(playbookGR, 'Canceled due to the incident closure or cancellation.');
13+
}
14+
15+
})(current, previous);

0 commit comments

Comments
 (0)