Set Incident State to Closed after all incident_task states are closed

Rajkumar10
Tera Contributor

I am looking to setup a Business Rule that will set the incident state to 'Closed' when all Incident_task states are Closed complete .

 

Any suggestions?

1 ACCEPTED SOLUTION

Alikutty A
Tera Sage

Hello,

You will need to write an after business rule on the incident_task table with condition as

State changes to Closed Complete and Script as

var inc = new GlideRecord("incident_task");
inc.addEncodedQuery('state!=3^parent='+current.parent);
inc.query();
if (!inc.hasNext()){
var incident = new GlideRecord('incident');
if(incident.get(current.parent)){
 incident.state = 7; //Replace your closed state value
 incident.close_code = 'Solved (Permanently)';  //Replace your close code value
 incident.close_notes = "Test notes";
 incident.update();
}
}

 

View solution in original post

2 REPLIES 2

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

have a look at the solution provided to the discussion below, it will fit your need:

Set Incident Task to Resolved after all tasks are closed

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

Alikutty A
Tera Sage

Hello,

You will need to write an after business rule on the incident_task table with condition as

State changes to Closed Complete and Script as

var inc = new GlideRecord("incident_task");
inc.addEncodedQuery('state!=3^parent='+current.parent);
inc.query();
if (!inc.hasNext()){
var incident = new GlideRecord('incident');
if(incident.get(current.parent)){
 incident.state = 7; //Replace your closed state value
 incident.close_code = 'Solved (Permanently)';  //Replace your close code value
 incident.close_notes = "Test notes";
 incident.update();
}
}