Background Scripts
Report Incidents with Inactive Assignment Groups
Find active incidents routed to inactive assignment groups so administrators can review ownership. Read-only: no incident or group records are changed.
(function () {
var prefix = '[SN-Tricks:InactiveAssignmentGroups]';
var maxRows = 100;
try {
var incident = new GlideRecord('incident');
incident.addQuery('active', true);
incident.addNotNullQuery('assignment_group');
incident.addQuery('assignment_group.active', false);
incident.orderBy('number');
incident.orderBy('sys_id');
incident.setLimit(maxRows + 1);
incident.query();
var reported = 0;
var truncated = false;
while (incident.next()) {
if (reported >= maxRows) {
truncated = true;
break;
}
gs.info(prefix + ' Incident=' + incident.getValue('number') +
' | sys_id=' + incident.getUniqueValue() +
' | inactive group=' + incident.getDisplayValue('assignment_group') +
' | group sys_id=' + incident.getValue('assignment_group'));
reported++;
}
gs.info(prefix + ' Reported ' + reported + ' incident(s).' +
(truncated ? ' Additional matches exist; output capped at ' + maxRows + '.' : ' All matches shown.') +
' No records were changed.');
} catch (error) {
gs.error(prefix + ' Report failed; output may be incomplete: ' + error.message);
}
})();How to use it
1. Run in a sub-production instance first, as an authorized administrator in the Global scope under System Definition > Scripts - Background. 2. The script reports active incidents whose populated assignment group is inactive; unassigned incidents and inactive incidents are excluded. 3. Review the prefixed system log entries. Output is capped at 100 incident rows, with a notice if more matches exist. This is not a total-count report. 4. Check each group and incident before manually changing ownership through your normal process. The script never reassigns or updates records. 5. Test with an active incident assigned to an inactive group, an active group, a blank group, and an inactive incident. Only the first should appear. Test no matches and more than 100 matches as well. 6. Results reflect the execution context and domain visibility. Logs contain record identifiers and group names; restrict access according to your instance policy.
Adapt the table names, fields, and conditions to your instance. Test the behavior in a development environment before using it in production.