Skip to content

Commit bef4279

Browse files
authored
When Group is marking as inactive, check open tickets (#2615)
* Create ReadMe.md * Create Code.js
1 parent de359a1 commit bef4279

File tree

2 files changed

+31
-0
lines changed
  • Server-Side Components/Business Rules/When Group is making inactive

2 files changed

+31
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
(function executeRule(current, previous /*null when async*/) {
2+
3+
// Run only when group is being inactivated
4+
if (current.active.changes() && current.active == false) {
5+
6+
var openTicketCount = 0;
7+
8+
// List of task tables to check
9+
var taskTables = ['incident', 'problem', 'change_request'];
10+
11+
for (var i = 0; i < taskTables.length; i++) {
12+
var gr = new GlideRecord(taskTables[i]);
13+
gr.addQuery('assignment_group', current.sys_id);
14+
gr.addQuery('active', true);
15+
gr.query();
16+
if (gr.hasNext()) {
17+
openTicketCount++;
18+
break; // We found at least one open ticket, no need to continue
19+
}
20+
}
21+
22+
// If open tickets exist, stop the update
23+
if (openTicketCount > 0) {
24+
gs.addErrorMessage('Cannot deactivate "' + current.name +
25+
'" group, because there are open tickets assigned to it.');
26+
current.setAbortAction(true);
27+
}
28+
}
29+
30+
})(current, previous);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
When marking a group as inactive, verify that there are no open tickets assigned to it from 'incident', 'problem', 'change_request' tables. If any open tickets are found, abort the deactivation process.

0 commit comments

Comments
 (0)