File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Server-Side Components/Background Scripts/Incident Reassignment Tracker Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments