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

Filipe Cruz
Kilo Sage
Kilo Sage

Hello @pritimayee1@gmail ,

 

You can do it by using a simple business rule, triggered when catalog task state is set to "closed Complete", to run the following code:

closeRelatedTasks();

function closeRelatedTasks(){
  var gr = new GlideRecord("sc_task");
  gr.addQuery("requested_item", current.requested_item);
  gr.addQuery("sys_id", "!=", current.sys_id); //exclude current task
  gr.query();
  while(gr.next()){
     gr.state = 7; //Closed Skipped
     gr.update();
  }

  var ritm = new GlideRecord("sc_req_item");
  ritm.get(current.requested_item);
  
  if(ritm){
     ritm.state = 7; //Closed skipped
     ritm.update();
  }

}

 

Maybe you need to change the state codes I inserted there.

 

In order for you to do it in flow designer, you need to create a new Flow with a trigger on top of the sc_task table when the state changes to "Closed Complete" or "Closed Skipped".

The action should contain the code I mentioned before.

 

If you consider this answer is helping you, please mark it as "Helpful".

 

Thanks!

Hi Filipe,

thank you for reply. I need to make all task state to closed skipped when any of the task is getting closed skipped or closed incomplete.

Suppose task1,task2,task3 and task 4 are generating at a time if suppose task 2 is getting closed skipped or closed incomplete then task 3 and task4 also will get automatically closed skipped.

Hello! So if task3 is the one being closed skipped/incomplete, then only task4 is being ser to closed skipped?

Pavankumar_1
Mega Patron

Hi pritimayee,

This can be archived with the simple flow using flow designer.

Trigger conditions:

 

find_real_file.png

 

Action: Select Update multiple records action and right side data section drag and drop the catalog task table.

On conditions

1. select the Request item field on catalog task table(sc_task) 

2. state is not closed complete // if tasks are closed complete ignore or add required conditions

 

 

find_real_file.png

 

Fields section: update the state as closed Incomplete.

 

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