Skip to content

Commit c4a541f

Browse files
Incident Reassignment Tracker.js
1 parent 725b669 commit c4a541f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
(function() {
2+
var MAX_REASSIGNMENTS = 5;
3+
var flaggedIncidents = [];
4+
var flaggedCount = 0;
5+
var totalChecked = 0;
6+
var incGR = new GlideRecord('incident');
7+
incGR.addActiveQuery();
8+
incGR.query();
9+
while (incGR.next()) {
10+
totalChecked++;
11+
// Count how many times 'assigned_to' changed
12+
var auditAgg = new GlideAggregate('sys_audit');
13+
auditAgg.addQuery('documentkey', incGR.getUniqueValue());
14+
auditAgg.addQuery('fieldname', 'assigned_to');
15+
auditAgg.addAggregate('COUNT');
16+
auditAgg.query();
17+
var reassignmentCount = 0;
18+
if (auditAgg.next()) {
19+
reassignmentCount = parseInt(auditAgg.getAggregate('COUNT'), 10);
20+
}
21+
// Flag incidents exceeding threshold
22+
if (reassignmentCount > MAX_REASSIGNMENTS) {
23+
flaggedIncidents.push(incGR.getValue('number'));
24+
flaggedCount++;
25+
}
26+
}
27+
gs.info(' Checked: ' + totalChecked + ' | Flagged: ' + flaggedCount + ' | Threshold: ' + MAX_REASSIGNMENTS);
28+
if (flaggedIncidents.length > 0)
29+
gs.info(' Flagged Incidents: ' + flaggedIncidents.join(', '));
30+
else
31+
gs.info(' No incidents exceeded the reassignment threshold.');
32+
})();

0 commit comments

Comments
 (0)