Skip to content

Commit 698e03a

Browse files
SLA Compliance Ratio by Assignment Group (#2478)
* Create SLA Compliance Ratio by Assignment Group This script calculates the SLA breach percentage for each assignment group based on closed incidents in ServiceNow. It leverages GlideAggregate to count both total SLAs and breached SLAs efficiently, providing key SLA performance insights. * Update SLA Compliance Ratio by Assignment Group * Delete Core ServiceNow APIs/GlideAggregate/SLA Compliance Ratio by Assignment Group * Created script.js * Created readme.md * Update script.js
1 parent 9c6a656 commit 698e03a

File tree

2 files changed

+41
-0
lines changed
  • Core ServiceNow APIs/GlideAggregate/SLA Compliance Ratio by Assignment Group

2 files changed

+41
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Overview
2+
3+
This script calculates the SLA breach percentage for each assignment group based on closed incidents in ServiceNow.
4+
It leverages GlideAggregate to count both total SLAs and breached SLAs efficiently, providing key SLA performance insights.
5+
6+
Useful for:
7+
• SLA dashboards
8+
• Support performance tracking
9+
• Service improvement reports
10+
11+
Objective
12+
13+
To determine, for each assignment group:
14+
• How many SLAs were closed
15+
• How many of those breached
16+
• The resulting SLA compliance percentage
17+
18+
Script Logic
19+
1. Query the task_sla table.
20+
2. Filter for closed SLAs linked to incidents.
21+
3. Aggregate total SLAs (COUNT) and breached SLAs (COUNT, 'breach', 'true').
22+
4. Group results by assignment group.
23+
5. Calculate breach percentage.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
(function() {
2+
var ga = new GlideAggregate('task_sla');
3+
ga.addEncodedQuery('task.sys_class_name=incident^active=false');
4+
ga.addAggregate('COUNT'); // All SLAs
5+
ga.addAggregate('COUNT', 'breach', 'true'); // breached SLAs
6+
ga.groupBy('task.assignment_group');
7+
ga.query();
8+
9+
gs.info('SLA Compliance Ratio by Group');
10+
11+
while (ga.next()) {
12+
var total = parseInt(ga.getAggregate('COUNT'));
13+
var breached = parseInt(ga.getAggregate('COUNT', 'breach', 'true'));
14+
var rate = breached ? ((breached / total) * 100).toFixed(2) : 0;
15+
gs.info(ga.getDisplayValue('task.assignment_group') + ': ' + rate + '% breached (' + breached + '/' + total + ')');
16+
}
17+
18+
})();

0 commit comments

Comments
 (0)