Parallel Tasks and Conditions

MattSN
Mega Sage
Mega Sage

I feel like I'm missing the obvious. I have need to run 2 tasks in parallel, however one of them should only be created under some conditions. The problem is:

  • The workflow always sticks at the join statement waiting for task2, even if it is not created.
  • If I don't point task2 output at the join statement, then the flow is ended after task1 completes.

How do you make 2 tasks run in parallel, while making one of them conditionally created? I could place the condition after task2 is created and then skip it, but I'd like to avoid creating it entirely.

 

paralell.PNG

1 ACCEPTED SOLUTION

MattSN
Mega Sage
Mega Sage

For anyone that comes across this I found a good tip on reddit.

https://www.reddit.com/r/servicenow/comments/wwhtfa/need_help_with_parallel_tasks_and_join/

Create a "Wait for Condition"  in place of the Join. A join doesn't work when using conditional inputs as it operates as a logical AND

var getTasks = new GlideRecord('sc_task');
getTasks.addEncodedQuery('active=true^request_item=' + current.sys_id);
getTasks.query();
if (getTasks.next()) {
    answer = false;
} else {
    answer = true;
}

 

View solution in original post

3 REPLIES 3

MattSN
Mega Sage
Mega Sage

For anyone that comes across this I found a good tip on reddit.

https://www.reddit.com/r/servicenow/comments/wwhtfa/need_help_with_parallel_tasks_and_join/

Create a "Wait for Condition"  in place of the Join. A join doesn't work when using conditional inputs as it operates as a logical AND

var getTasks = new GlideRecord('sc_task');
getTasks.addEncodedQuery('active=true^request_item=' + current.sys_id);
getTasks.query();
if (getTasks.next()) {
    answer = false;
} else {
    answer = true;
}

 

Mike_R
Kilo Patron
Kilo Patron

I think you need a "Branch" activity after Begin, and then connect the "Branch" to the If and Task1.

MattSN
Mega Sage
Mega Sage