When any one task is getting cancelled need to cancel rest all task and need to cancel the ritm

pritimayee
Tera Contributor

Can anyone please help me how to achieve this.

I am creating 4tasks at a time when the request is getting submitted. Tasks are getting created from flow designer. If any one of the task is getting closed complete or closed skipped rest all task need to set as closed skipped or closed incomplete  and ritm should get update as closed incomplete. Not able to do in flow designer.

 

5 REPLIES 5

Pavankumar_1
Mega Patron

Hi pritimayee,

create after Business rule on sc_task table

after giving conditions use below script on advanced tab

 

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

var sct = new GlideRecord('sc_task');

              // to find active records

    sct.addActiveQuery();

       //records for the same parent

    sct.addQuery("requested_item", current.requested_item);

//exclude current task record

  sct.addQuery("sys_id", "!=", current.sys_id); 

sct.query();

  while(sct.next()){

    sct.state = 7; 

    sct.update();

  }

//close the request item 

var ritmGr= new GlideRecord("sc_req_item");

ritmGr.get(current.getValue('requested_item'));

  if(ritmGr){

    ritmGr.state = 7; //Closed skipped

    ritmGr.update();

  }

})(current, previous);

 

Hope it helps!!

Please Mark Correct/helpful, if applicable, Thanks!! 

 

Regards

Pavankumar

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar