When parent incident gets closed, its associated child incidents should also get closed.

Parth_S
Tera Contributor

Which BR should i use for this case ?

After or Async ?

Is it possible by using both BR's ?

 

6 REPLIES 6

Runjay Patel
Giga Sage

Hi @Parth_S ,

 

You can write before BR and use below script.

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
var childIncidents = new GlideRecord('incident');
    childIncidents.addQuery('parent_incident', current.sys_id); 
    childIncidents.addQuery('active', true); 
    childIncidents.query();

    while (childIncidents.next()) {
       
        childIncidents.state = 7; 
        childIncidents.close_notes = 'Closed because the parent incident was closed.';
        childIncidents.update(); 
    }


})(current, previous);

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Part 2. In this video i have talked about overview on ServiceNow platform/tool. How you can opt for personal dev instance (PDI)? how to login in ServiceNow instance and navigation to OOB modules. For document please visit: https://servicenowwithrunjay.com/ Follow Facebook page for latest update on

Dr Atul G- LNG
Tera Patron

I echo with Ankur. The BR is OOTB to resolved the child incidents but closure will work on individual level.

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************