- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2014 03:49 AM
Hi,
I have a workflow which requires 4 change tasks to be completed before moving to the next stage - see attachment.
Does anyone have a script that could help.
Thanks
Steve
Solved! Go to Solution.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2014 07:44 AM
I would suggest to use join activity. It works the same way as you need it as per your problem description.
Utility Activities - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2014 07:28 AM
if a simple join after that wont' work for you you can set a script box after each task and set a variable to true..
workflow.scratchpad_task1 = 'true';
then in the wait for just wait for all four to turn true... i would put a variable initialization script in the beginning of the workflow that sets all four to false.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2014 07:44 AM
I would suggest to use join activity. It works the same way as you need it as per your problem description.
Utility Activities - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2014 08:33 AM
Thanks - This was to simple and has worked fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2014 07:45 AM
I use the below script in my Request workflows. This will wait for all Request Tasks to close, including any that may have been manually created (outside of Tasks created by the workflow). I had to build this into my Onboarding workflows as there were often unique tasks added to the Request Item after the ticket was created.
If you only use Tasks created by the workflow you can use a "Join," which pauses until all activities created by the workflow have been completed.
More info here: Condition Activities - ServiceNow Wiki
answer = true;
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.addQuery('wf_activity', '');
gr_tsk.query();
if (gr_tsk.next()) {
answer = false;
} else {
answer = true;
}