Skip to content
Closed
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,8 @@
**SLA Breached Incident Count by Assignment Group:**
This script uses the GlideAggregate API to calculate the total number of incidents with breached SLAs, grouped by their assignment group.

**Description:**
This snippet demonstrates how to use GlideAggregate to efficiently group and count ServiceNow records. It retrieves the number of incidents for which SLAs have been breached, grouped by each assignment group.

**Use Case:**
This is useful for identifying which support groups have the highest number of SLA breaches, helping improve response and resolution performance.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function getBreachedIncidentCountByGroup() {
var result = [];

var ga = new GlideAggregate('task_sla');
ga.addAggregate('COUNT');
ga.groupBy('task.assignment_group');
ga.addQuery('task.sys_class_name', 'incident');
ga.addQuery('task.active', true);
ga.addQuery('has_breached', true);
ga.query();

while(ga.next()){
var grpName = ga.getValue('task.assignment_group.name') || 'No Group';
var count = ga.getAggregate('COUNT');

result.push({
assignment_group: grpName,
breached_incident_count: parseInt(count, 10)
});

gs.info('Assignment Group: ' + grpName + ' - Breached Incidents: ' + count);
}
return result;
}
Loading