Close RITM only if all tasks are closed

sbeginner
Kilo Guru

Hi All,

I have a workflow that creates a single task and other tasks team creates for approvals and stuff. The issue is, once the 

workflow created task gets Closed the WF moves to end activity and stage is completed even when other manual tasks are still open. I tried writing a Before/update After/update BR but is not helping. Can you please help?

1 ACCEPTED SOLUTION

Rana5
Tera Expert

Create a Wait for condition with following script:

 

var task = new GlideRecord("sc_task");
task.addEncodedQuery("stateNOT IN3,4^request_item=" + current.sys_id);
task.query();
var count = task.getRowCount();
if (count == 0)
answer = true;

 

You can put this inside a function as well. No need of any BR or additional field on RITM level.

 

Regards,

Rana

View solution in original post

13 REPLIES 13

Hi @Community Alums, the All Tasks Closed field is on RITM and setting to true via after update BR.

Community Alums
Not applicable

Additional field is not required. you can put the above script in the wait for condition activity.

Nayan  Dhamane
Kilo Sage
Kilo Sage

Hello @sbeginner ,

 

checking will provide you the required code.

BR,
Nayan

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Rana5
Tera Expert

Create a Wait for condition with following script:

 

var task = new GlideRecord("sc_task");
task.addEncodedQuery("stateNOT IN3,4^request_item=" + current.sys_id);
task.query();
var count = task.getRowCount();
if (count == 0)
answer = true;

 

You can put this inside a function as well. No need of any BR or additional field on RITM level.

 

Regards,

Rana