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,30 @@
(function executeRule(current, previous /*null when async*/) {

// Run only when group is being inactivated
if (current.active.changes() && current.active == false) {

var openTicketCount = 0;

// List of task tables to check
var taskTables = ['incident', 'problem', 'change_request'];

for (var i = 0; i < taskTables.length; i++) {
var gr = new GlideRecord(taskTables[i]);
gr.addQuery('assignment_group', current.sys_id);
gr.addQuery('active', true);
gr.query();
if (gr.hasNext()) {
openTicketCount++;
break; // We found at least one open ticket, no need to continue
}
}

// If open tickets exist, stop the update
if (openTicketCount > 0) {
gs.addErrorMessage('Cannot deactivate "' + current.name +
'" group, because there are open tickets assigned to it.');
current.setAbortAction(true);
}
}

})(current, previous);
Original file line number Diff line number Diff line change
@@ -0,0 +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.
Loading