Auto close the related child task on closure of parent task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2019 02:13 AM
Hi All ,
I have a requirement
- All the child tasks should closed when closing the parent task which are tagged under parent task.
- Parent task contains 500 child tasks are tagged. If Parent task is closed then all the 500 child task should be closed.
How should I achieve this.
- Labels:
-
Incident Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2019 02:19 AM
Hi Roshani,
have an after update business rule on parent task table; condition as state changes to closed
In the script section; add this
1) query child task table with parent field as current record sys_id
2) for every child task iterate and set the state as closed
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
11-19-2019 02:20 AM
Depending on the table you're using there might be some out of the box functionality you can leverage for this. Check out the business rules on the table to see if you can find anything.
If not, you'll need to use an after update business rule set to trigger when the state changes or when active changes to false depending on how you want it to work. You need to glide into the table and find all child record and then update them with the closure details of the parent eg:
var gr = new GlideRecord('table_name');
gr.addQuery('parent', current.getUniqueValue());
gr.addActiveQuery();
gr.query()
while(gr.next()){
gr.state = current.state;
gr.close_notes = current.close_notes;
//add more lines for any other fields you want to update
gr.update();
}
you might actually want to make the business rule asynchronous, if there are 500 records it might take a while to execute which will freeze the form for your user if you stick with an after update rule.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2019 02:23 AM
I'd advise using an Async Business Rule (not after - because you said you have 500 tasks) for this on the 'Parent Task' table, with a condition like 'Status' changes to "Closed". Async means control will be returned to the user immediately after they close the Parent record while the business rule execution takes place in the background.
You would need to write a script to query all Child Tasks and Close them. Something like this:
// Code not tested, provided as an example
var CLOSED_STATE = 7;// Your closed state here
var grChild = new GlideRecord('child_table');
grChild.addQuery('parent',current.sys_id);
grChild.addActiveQuery();
grChild.query();
while (grChild.next() ) {
grChild.state = CLOSED_STATE;
grChild.work_notes = 'Task closed from Parent';
grChild.update();
}
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022