Wait for all tasks to be closed completed.

Naresh291
Tera Contributor

Hi ,

I have a workflow that kicks out three tasks . My requirement is to have all three tasks closed after which the request would be set to closed complete .

I was thinking about Wait for condition , but not sure how to use it .

Can anyone please provide me with ideas/script for implementing this .

 

Regards,

Naresh

6 REPLIES 6

Allen Andreas
Administrator
Administrator

Hi,

If you are issuing each task 1 at a time, you can have the workflow wait for each one to be completed before moving on to the next. If you need to use 3 tasks at one time, then you can branch in to those 3 lanes, and use a join activity to join them all together. then drag the complete and incomplete lines from the join, to the set value activity of which you'd set the workflow stage to complete and then go to the end.

The join will hold everything together until all three incoming lines (from those tasks) reach it before jointly moving on to the next activity.

A wait for condition only "waits" for "something" on the current record, which is usually the request item, so that wouldn't help you unfortunately.

Check out the join activity and my design suggestion above. Thanks!

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi Allen,

 

In my workflow there are total 3 tasks created . Task 1 and Task 3 are created at the same time . Task 2 is created based on the selection of yes or no in one of the variable in task 1 .

 

Hi,

Ok. So essentially, you'd want those lines from all tasks to feed in to that Join. The idea and context still remains. Whether it's 2 or 3, etc.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

asifnoor
Kilo Patron

Hello Naresh,

Assuming that you have created the tasks from the workflow. In the task creation activity, you see a checkbox "wait for completion" select that so that the activity moves forward only once the task is closed.

You can also use wait for condition, but that will help only when you update the RITM back whenever its associated task is closed, such as updating worknotes of RITM whenever the task is closed. If thats the case, then yo ucan simply write a script inside wait for condition like this.

//check if tasks are closed or not. To be used under wait for condition of RITM
// Set the variable 'answer' to true or false to indicate if the condition has been met or not.

var gr = new GlideRecord("sc_task");
gr.addEncodedQuery("stateNOT IN3,4,7^request_item="+current.sys_id);
gr.query();
if(gr.next()) {
  answer = false;
} else {
  answer = true;
}

Mark the comment as a correct answer and helpful if this helps to solve the problem.