- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 03:28 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 05:29 PM
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 05:29 PM
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 05:30 PM
I think you need a "Branch" activity after Begin, and then connect the "Branch" to the If and Task1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2022 05:58 AM
There is also a potentially better solution here