forked from ServiceNowDevProgram/code-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
18 lines (15 loc) · 711 Bytes
/
script.js
File metadata and controls
18 lines (15 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 + ')');
}
})();