Request an enhancement where, if we receive a "clear", the parent (and child) incidents closed.

Ajay Singh2
Tera Contributor

Hello All,

 

I have a requirement like "We currently have a business rule setup for incidents generated by abc, where it creates child tickets based on correlation ID. I would like to request an enhancement where, if we receive a "clear",(like short_description contains Clear and based on this) the parent (and child) incidents are automatically closed.

 

Can anyone help how to achieve this.

 

Thank You!!

13 REPLIES 13

@Ajay Singh2 

Use the below script

 

SupriyaBasak_0-1728299232940.png

 

 

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

//check if update is valid or aborted before updating child incidents
if(current.isActionAborted())
return;

var incident = new GlideRecord("incident");
incident.addActiveQuery();
incident.addQuery("sys_id", current.parent_incident.sys_id);
incident.addQuery("state", "!=", IncidentState.RESOLVED);
incident.query();
var parentClose = true;
if (incident.next()) {
var child = new GlideRecord("incident");
child.addActiveQuery();
child.addQuery("parent_incident", incident.sys_id);
child.addQuery("state", "!=", IncidentState.RESOLVED);
child.query();
if(child.next()){parentClose = false;}

if(parentClose){
incident.state = IncidentState.RESOLVED;
 
incident.close_notes = current.close_notes;
 
incident.close_code = current.close_code;
incident.comments = current.comments;
 
incident.work_notes = current.work_notes;
incident.update();}
}
})(current, previous);
 

If my answer helped you in any way, please then mark it as helpful or correct. This will help others finding a solution.

 

Thanks,

Supriya

If my answer helped you in any way, please then mark it as helpful or correct. This will help others finding a solution.

Thanks,
Supriya

@SupriyaBasak 

In when to run condition, I need to add Short description contains Clear. Because Incident need to closed when it will get the Clear in short description than i need to close the incident.

 

Thank You!!

@Ajay Singh2 Please update the condition as per your requirement. I hope that the solution worked for you,

 

If my answer helped you in any way, please then mark it as helpful or correct. This will help others finding a solution.

 

Thanks,

Supriya

If my answer helped you in any way, please then mark it as helpful or correct. This will help others finding a solution.

Thanks,
Supriya

Mark Manders
Mega Patron

Can you close this tread, since you moved on to this one: https://www.servicenow.com/community/riseup-with-servicenow-forum/how-to-close-the-parent-incident-b...


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark