Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Auto resolve case when related inc and chg is resolved and closed

Alex D Great
Tera Contributor

Hi community

I have this current challenge where I need to auto resolve case (parent) when related inc AND/OR chg, req (childs) are resolved and closed. 

I manage to auto resolve case when only incident is resolved, however, when a second task type is related it becomes harder. Any help is highly appreciated.

6 REPLIES 6

Thanks for your reply @jaheerhattiwale 

Sorry , but how to write this as script in br?

@Alex D Great You can create a after business rule on "Task [task]" table as below

jaheerhattiwale_0-1670409210335.png

 

jaheerhattiwale_1-1670409229521.png

 

 

Script: 

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

var allTasks = new GlideRecord("task");
allTasks.addQuery("active=true^state!=6"); //6 is resolved state
allTasks.addQuery("parent="+current.parent.toString());
allTasks.query();

if(!allTasks.next()){
var caseGr = new GlideRecord("sn_customerservice_case");
if(caseGr.get(current.parent.toString())){
caseGr.state = 3; //3 is closed state
caseGr.update();
}
}

})(current, previous);

 

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023