File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Server-Side Components/Business Rules/When Group is making inactive Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ ( function executeRule ( current , previous /*null when async*/ ) {
2+
3+ // Run only when group is being inactivated
4+ if ( current . active . changes ( ) && current . active == false ) {
5+
6+ var openTicketCount = 0 ;
7+
8+ // List of task tables to check
9+ var taskTables = [ 'incident' , 'problem' , 'change_request' ] ;
10+
11+ for ( var i = 0 ; i < taskTables . length ; i ++ ) {
12+ var gr = new GlideRecord ( taskTables [ i ] ) ;
13+ gr . addQuery ( 'assignment_group' , current . sys_id ) ;
14+ gr . addQuery ( 'active' , true ) ;
15+ gr . query ( ) ;
16+ if ( gr . hasNext ( ) ) {
17+ openTicketCount ++ ;
18+ break ; // We found at least one open ticket, no need to continue
19+ }
20+ }
21+
22+ // If open tickets exist, stop the update
23+ if ( openTicketCount > 0 ) {
24+ gs . addErrorMessage ( 'Cannot deactivate "' + current . name +
25+ '" group, because there are open tickets assigned to it.' ) ;
26+ current . setAbortAction ( true ) ;
27+ }
28+ }
29+
30+ } ) ( current , previous ) ;
You can’t perform that action at this time.
0 commit comments