diff --git a/Core ServiceNow APIs/GlideAggregate/SLA Compliance Ratio by Assignment Group/readme.md b/Core ServiceNow APIs/GlideAggregate/SLA Compliance Ratio by Assignment Group/readme.md new file mode 100644 index 0000000000..a85f5490ec --- /dev/null +++ b/Core ServiceNow APIs/GlideAggregate/SLA Compliance Ratio by Assignment Group/readme.md @@ -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. diff --git a/Core ServiceNow APIs/GlideAggregate/SLA Compliance Ratio by Assignment Group/script.js b/Core ServiceNow APIs/GlideAggregate/SLA Compliance Ratio by Assignment Group/script.js new file mode 100644 index 0000000000..a31caa5a59 --- /dev/null +++ b/Core ServiceNow APIs/GlideAggregate/SLA Compliance Ratio by Assignment Group/script.js @@ -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 + ')'); + } + +})();