Background Scripts
Report Active Incidents Without Assignment Groups
Find active incidents with an empty assignment group for manual queue triage, without assigning records or sending notifications.
(function reportUngroupedIncidents() {
var prefix = '[SN-Tricks:UngroupedIncidents]';
var limit = 100;
try {
var incidents = new GlideRecord('incident');
incidents.addQuery('active', true);
incidents.addNullQuery('assignment_group');
incidents.orderBy('sys_created_on');
incidents.orderBy('sys_id');
incidents.setLimit(limit + 1);
incidents.query();
var shown = 0;
var truncated = false;
while (incidents.next()) {
if (shown >= limit) {
truncated = true;
break;
}
gs.info(prefix + ' incident=' + incidents.getValue('number') +
' sys_id=' + incidents.getUniqueValue() +
' created=' + incidents.getValue('sys_created_on'));
shown++;
}
gs.info(prefix + ' Reported ' + shown + ' active incident(s) without an assignment group.' +
(truncated ? ' More matches exist; output capped at ' + limit + '.' : ' All matching incidents shown.'));
} catch (error) {
gs.error(prefix + ' Report failed; disregard partial output: ' + error);
}
})();How to use it
1. As an authorized administrator, open System Definition > Scripts - Background in a sub-production instance and select Global scope. This custom diagnostic reads OOB Incident [incident] fields. No cross-scope access is required in Global. Keep limit a positive whole number. 2. Run the script and search output or system logs for [SN-Tricks:UngroupedIncidents]. It filters Active is true and Assignment group is empty, then lists up to 100 records, oldest creation time first with sys_id as a tie-breaker. One extra row detects truncation. The reported count is not a full total when capped. 3. Test active incidents with and without groups and inactive incidents without groups. Only active incidents without groups should appear. An Assigned to value does not exclude a record: this report checks group assignment, not individual assignment. Compare with the incident list using the same filters and domain context. 4. Test zero, exactly 100, and 101 matches. Only 101 should report truncation. Check ordering and verify that no incident fields change. JavaScript syntax and local mock tests are not substitutes for validation on your ServiceNow instance. 5. An empty group can be intentional or temporary. Review assignment rules, flows, and routing requirements before taking action. This does not identify invalid nonempty references, inactive groups, SLA breaches, or the cause of missing assignment. 6. Administrative GlideRecord is not an ACL-filtered end-user report. Domain separation, query business rules, and concurrent updates affect results. Output includes internal incident identifiers and creation timestamps, but no descriptions or caller details; restrict log access appropriately. A row cap limits output, not database scan cost. 7. On any error, disregard partial output. The script performs no inserts, updates, deletes, or notifications, so no data rollback is required. Ad hoc execution creates no reusable configuration to capture in an update set.
Adapt the table names, fields, and conditions to your instance. Test the behavior in a development environment before using it in production.