File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Server-Side Components/Business Rules/Abort Parent Incident Closure When Child is Open Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1+ ( function executeRule ( current , previous /*null when async*/ ) {
2+
3+ // Query for any child incidents related to the current parent incident.
4+ var childIncidents = new GlideRecord ( 'incident' ) ;
5+ childIncidents . addQuery ( 'parent_incident' , current . sys_id ) ;
6+ childIncidents . addEncodedQuery ( 'state!=6^ORstate!=7^ORstate!=8' ) ; // state is not closed,Resoved,cancelled
7+ childIncidents . addActiveQuery ( ) ;
8+ childIncidents . query ( ) ;
9+ // Check if any open child incidents were found.
10+ if ( childIncidents . getRowCount ( ) > 0 ) {
11+ var childNumbers = [ ] ;
12+ while ( childIncidents . next ( ) ) {
13+ childNumbers . push ( childIncidents . number . toString ( ) ) ;
14+ }
15+ // Display an error message with the open child incident numbers.
16+ gs . addErrorMessage ( 'Cannot close this incident. Please close the following child incidents first: ' + childNumbers . join ( ', ' ) ) ;
17+ //prevent saving the record
18+ current . setAbortAction ( true ) ;
19+ }
20+
21+ } ) ( current , previous ) ;
You can’t perform that action at this time.
0 commit comments