- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2017 12:24 PM
Hello all,
I have a RUN SCRIPT that creates multiple tasks based on a list collector but after it creates the tasks the workflow continues and closes the RITM. I need the RITM to stay open until all of the SCTASK have been closed.
I have tried using this script with a 'Wait for Condition' and while it does stop the RITM from closing, once all the SCTASK have been closed the RITM stay's open.
//Query for all tasks to see if they are inactive
var rec = new GlideRecord('sc_task');
rec.addQuery('request_item', current.sys_id);
rec.addQuery('active', true);
rec.query();
if(rec.hasNext()){
answer = false;
}
else{
//Continue
answer = true;
}
Thank you for any help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2017 12:32 PM
This is likely caused by the fact that the catalog tasks' closure is not triggering the workflow to continue running. What you'll need to do is create a business rule on the catalog task that triggers the RITM's workflow when the task is closed. That script will look something like this:
var ritmRec = new GlideRecord('sc_req_item');
if(ritmRec.get(current.request_item)) {
new Workflow().broadcastEventToCurrentsContexts(ritmRec, 'update', null);
}
PS - this BR on the catalog task table should be an after BR as it is interacting with another table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2017 12:34 PM
Hi Jacob,
Could you try using rec.next() instead of rec.hasNext().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2017 12:38 PM
Jaspal,
Thanks but it did not work.