diff --git a/Server-Side Components/Background Scripts/Get Inactive Assignment Groups/README.md b/Server-Side Components/Background Scripts/Get Inactive Assignment Groups/README.md new file mode 100644 index 0000000000..6354dd4426 --- /dev/null +++ b/Server-Side Components/Background Scripts/Get Inactive Assignment Groups/README.md @@ -0,0 +1,5 @@ +# ServiceNow Background Script – Identify Inactive Assignment Groups + +## Overview +This background script identifies **assignment groups that have no active members**. +Such groups can cause issues with **incident routing**, **task assignment**, or **notification delivery**, since tickets assigned to these groups may never reach an active user. diff --git a/Server-Side Components/Background Scripts/Get Inactive Assignment Groups/get_inactive_assignment_groups.js b/Server-Side Components/Background Scripts/Get Inactive Assignment Groups/get_inactive_assignment_groups.js new file mode 100644 index 0000000000..03f67e028e --- /dev/null +++ b/Server-Side Components/Background Scripts/Get Inactive Assignment Groups/get_inactive_assignment_groups.js @@ -0,0 +1,21 @@ +var activeGroups = {}; +var member = new GlideAggregate('sys_user_grmember'); +member.addQuery('user.active', true); +member.groupBy('group'); +member.query(); +while (member.next()) { + activeGroups[member.group.toString()] = true; +} + +var inactiveCount = 0; +var grp = new GlideRecord('sys_user_group'); +grp.addQuery('active', true); // optional filter +grp.query(); +while (grp.next()) { + if (!activeGroups[grp.sys_id.toString()]) { + gs.info('Inactive group (no active members): ' + grp.name); + inactiveCount++; + } +} + +gs.info('Total inactive groups found: ' + inactiveCount);