Wait for and IF workflow conditions

Bogdan18
Tera Guru

Hi guys,

I have a workflow where just one Catalog Task is being created initially, then once this first Catalog Task is set on Closed Complete 2 other Catalog Tasks are opened. Now if both these tasks are closed complete then other tasks are being opened.

If I put any of these 2 tasks, that are opened after the first one gets closed complete, on Closed Incomplete then the entire RITM gets Closed Cancelled, which is great as this is what we want.

 

If I put the first of these 2 tasks on Closed Complete and then the second on Closed Incomplete then the entire RITM gets closed cancelled which is fine but it is also opening the rest of the other tasks and set them on Closed Incomplete. This is not what we want. So if the second task of the 2 is set on Closed Incomplete or Skipped I would like to Close Cancel the RITM but not have the Workflow open the rest of the tasks.

I have a wait for condition that waits for both tasks to get closed complete and then the other tasks are being opened but it seems to fail if i put the first tasks of those 2 in the Closed Complete state and then the second one in the Closed Incomplete state. I also tried to set an If condition but that seems to fail as well.

 

Script include in the wait for condition:

function WfWaitForAllTasksToClose() {

var gr_tsk = new GlideRecord("sc_task");
gr_tsk.addQuery('request_item', current.sys_id);
gr_tsk.addQuery('state', '!=', '3');
gr_tsk.addQuery('state', '!=', '4');
gr_tsk.addQuery('state', '!=', '7');
gr_tsk.query();

if (gr_tsk.next())
answer = false;
else
answer = true;

}

 

and this is the workflow:

find_real_file.png

Thanks,

Bogdan

1 ACCEPTED SOLUTION

Bogdan18
Tera Guru

Found the answer here: https://community.servicenow.com/community?id=community_question&sys_id=dcdac76ddb5cdbc01dcaf3231f9619ec&view_source=searchResult 

 

Thanks anyway guys,

Bogdan

View solution in original post

1 REPLY 1

Bogdan18
Tera Guru

Found the answer here: https://community.servicenow.com/community?id=community_question&sys_id=dcdac76ddb5cdbc01dcaf3231f9619ec&view_source=searchResult 

 

Thanks anyway guys,

Bogdan