Skip to content
Merged
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,23 @@
Overview

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.

Useful for:
• SLA dashboards
• Support performance tracking
• Service improvement reports

Objective

To determine, for each assignment group:
• How many SLAs were closed
• How many of those breached
• The resulting SLA compliance percentage

Script Logic
1. Query the task_sla table.
2. Filter for closed SLAs linked to incidents.
3. Aggregate total SLAs (COUNT) and breached SLAs (COUNT, 'breach', 'true').
4. Group results by assignment group.
5. Calculate breach percentage.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(function() {
var ga = new GlideAggregate('task_sla');
ga.addEncodedQuery('task.sys_class_name=incident^active=false');
ga.addAggregate('COUNT'); // All SLAs
ga.addAggregate('COUNT', 'breach', 'true'); // breached SLAs
ga.groupBy('task.assignment_group');
ga.query();

gs.info('SLA Compliance Ratio by Group');

while (ga.next()) {
var total = parseInt(ga.getAggregate('COUNT'));
var breached = parseInt(ga.getAggregate('COUNT', 'breach', 'true'));
var rate = breached ? ((breached / total) * 100).toFixed(2) : 0;
gs.info(ga.getDisplayValue('task.assignment_group') + ': ' + rate + '% breached (' + breached + '/' + total + ')');
}

})();
Loading