How do I Close RITM , once tasks are closed (RITM and tasks are created through script in Runscript activity).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2018 08:41 AM
After first RITM and its task is closed , I am creating another additional RITM with 5 tasks in a Runscript activity.Everything is fine but when I close all the tasks, it doesnt close the RITM . Which is working fine for the first RITM automatically but its not doing the same for the tasks and its RITM which are created through script.Can anyone advise on how do I trigger RITM to close once all the tasks are closed??
- Labels:
-
Best Practices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2018 10:31 AM
Out of the box there is a business rule that runs on the task table called SNC - Run parent workflows IF:
task state changes to 3 (Closed Complete) or task state changes to 4 (Closed Incomplete) or task state changes to 7 (Cancelled)
If it meets these conditions then it will query for workflows running on the parent task and broadcast an "update" workflow event. I mention this because you can leverage this in your workflow:
- After your run script that creates the 5 tasks, use an If activity to check for open child tasks
- If open tasks then use a Wait for WF event to wait for "update" and then go back to your If activity checking for open tasks
- This will continue to loop until all tasks are closed
- Once the tasks are closed, go to a set values of closed and done
Here is an example I used for testing purposes where I generate one task and then manually created other child tasks. Again in your situation you would be replacing the Child Task (Catalog Task) activity with your run script that creates the 5 tasks.
Here is the script in the If activity:
answer = ifScript();
function ifScript() {
var childTask = new GlideRecord("task");
childTask.addActiveQuery();
childTask.addQuery("parent", current.sys_id);
childTask.query();
if (childTask.hasNext()) {
return 'yes';
} else {
return 'no';
}
}
Here is what the Wait for EF Event activity is set to:
Please mark this post as helpful of the correct answer to your question if applicable so others viewing can benefit.