Close child cases when parent is closed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2020 09:40 PM
In HR case, when parent case state is changed to closed complete, if any of the child cases are not closed, then error/info message has to show up saying child cases are not closed.
This has to happen without scripting. Any suggestions on this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2020 01:13 AM
Similar to below query as per the relation field whatever field is there in HR module which holds sys_id of parent
var rec = new GlideRecord("incident");
rec.addQuery("parent_incident", current.sys_id);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2020 12:44 AM
Yes you can write custom BR but you have to make in-active the OOB BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2020 02:42 AM
What are the other options apart from business rule i can use?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2020 03:32 AM
Business Rule is really the way to go. You could try to do something with workflow editor or Flow designer as well, but it would still require some scripting and it would be more complex. You could also write a UI Action (make a button) that would close the case and all child tasks, however this would also require some scripting to accomplish. No way to do it that I am aware of that does not involve writing a script of some sort.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2020 06:09 AM
Hello-
As everyone here is stating, Business Rule would be the way to go, to abort the closing of the parent case while the child case is still active.
For our system, we had a BR to abort the closing of a case when there was an hr task attached, that was still active.
So, I basically took that logic and applied it to a BR for Parent and Child cases. Here is what we have:
For the advanced tab:
Condition: current.state.changesTo(20)
Script:
(function executeRule(current, previous /*null when async*/) {
var recObj = new GlideRecord('sn_hr_core_case');
recObj.addQuery('parent', current.sys_id);
recObj.addQuery('active', 'true');
recObj.query();
if (recObj.hasNext()) {
gs.addErrorMessage('Unable to close Case due to an open Child Case. All related Child Cases must be closed before closing the Case.');
current.setAbortAction(true);
}
})(current, previous);
of course, you could make your message something different, but this is what we have. So, if I try to close a parent case with an active child case:
Active HR Child Case with Active Parent Case:
While on the Parent Case and clicking on the Close Complete UI Action (to move to awaiting acceptance state):
Give this a try and do some testing - let us know if this works or not for you!
Cheers,
-Rob