have to create a business rule to close the RITM and REQ if the all related tasks got closed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2019 02:55 AM
the issue here is , few requests are not getting closed.
so i want to create a busienss rule to check all the related tasks are got closed or not.
if all closed it has to close the RITM and REQ.
if not it should not execute.
please help me with the sample code.
it has to check manual tasks as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2019 03:44 AM
Hi,
I might not have understood the requirement correctly.
But this is the OOB functionality available in Service Now.
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2019 04:35 AM
no i did not found any OOB related to my issue.
here i wants to create a functionality to close the RITM based on the related catalog tasks to that RITM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2019 04:39 AM
Hi,
I have posted sample script for the same in the below link; it is similar question asked by you
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2019 07:39 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.