From c7f2d3a86f38e9945b3ccd3bbf0bf1cf8e8603bf Mon Sep 17 00:00:00 2001 From: chaytarak <62869669+chaytarak@users.noreply.github.com> Date: Wed, 29 Oct 2025 20:02:09 +0530 Subject: [PATCH 1/2] Create ReadMe.md --- .../Business Rules/When Group is making inactive/ReadMe.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Server-Side Components/Business Rules/When Group is making inactive/ReadMe.md diff --git a/Server-Side Components/Business Rules/When Group is making inactive/ReadMe.md b/Server-Side Components/Business Rules/When Group is making inactive/ReadMe.md new file mode 100644 index 0000000000..06a986ce5c --- /dev/null +++ b/Server-Side Components/Business Rules/When Group is making inactive/ReadMe.md @@ -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. From d1e5f9734b961dc8e84a1d2db95e00ecb7ffb94a Mon Sep 17 00:00:00 2001 From: chaytarak <62869669+chaytarak@users.noreply.github.com> Date: Wed, 29 Oct 2025 20:03:45 +0530 Subject: [PATCH 2/2] Create Code.js --- .../When Group is making inactive/Code.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Server-Side Components/Business Rules/When Group is making inactive/Code.js diff --git a/Server-Side Components/Business Rules/When Group is making inactive/Code.js b/Server-Side Components/Business Rules/When Group is making inactive/Code.js new file mode 100644 index 0000000000..5de78b85db --- /dev/null +++ b/Server-Side Components/Business Rules/When Group is making inactive/Code.js @@ -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);