When Parent Incident is Resolved all Child incidents are not getting Resolved for Incident

SNOW46
Tera Contributor

Hi All,

I have recently came up with an issue that whenever an Parent Incident is Resolved, related Child Incident/Incidents are not getting Resolved.

Even the OOB Script "Update Child Incidents" is enabled but its not working as expected.

Can anyone let me know if I need to modify the existing script or do I need to configure one separate script for the same.

 

Its an urgent requirement as too many users are getting impacted.

 

Thanks,

SNOW@Das

7 REPLIES 7

Brian Lancaster
Tera Sage

What version are you on of ServiceNow?

Kingston

Hi Das, 

 

Try with  the following business rule.

 

(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('incident');
      if (gr.get(current.parent_incident)) {

      if (checkIfAllChildIncidentsAreResolved()) {
             gs.addInfoMessage('All child incidents are now resolved, resolving parent incident');
             gr.incident_state = incidentState.RESOLVED;
             gr.update();
}
else {
gs.addInfoMessage('Not all child incidents are resolved');
}
}


else {


gs.addInfoMessage('Current incident does not have a parent incident');


}

 

function checkIfAllChildIncidentsAreResolved() {


var rec = new GlideRecord("incident");

rec.addQuery("parent_incident", current.parent_incident);

rec.addQuery("incident_state", "!=", IncidentState.RESOLVED);

rec.addActiveQuery();

rec.query();

 

// Check if there are any unresolved child incidents associated to the parent incident


if (rec.hasNext()) {

gs.addInfoMessage('There is an unresolved child incident');


return false;


}


else {


gs.addInfoMessage('All child incidents are resolved');


return true;


}

 

}

 


})(current, previous);

 


})(current, previous);

Hi,

Can you post some screenshots for the BR to be configured. And also let me know the ORDER what should be given?

 

Thanks..