- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2022 12:02 AM
Parent ticket should not be allowed to close with open child. Once after completing all the tasks, I should be able to close the parent task.
Thanks in advance!!!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2022 12:10 AM
before update business rule on the parent table, when state changes to closed complete or closed incomplete etc.(put the states you want to abort if there are active child tasks):
var grChildTasks = new GlideRecord('<table where child tasks are>');
grChildTasks.addQuery('parent', current.getUniqueValue());
grChildTasks.addActiveQuery();
grChildTasks.query();
if(grChildTasks.hasNext()){
gs.addInfoMessage('some message to notify the user that the action is aborted');
current.setAbortAction(true);
}
Please Mark Correct AND Helpful. thanks
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2022 12:10 AM
before update business rule on the parent table, when state changes to closed complete or closed incomplete etc.(put the states you want to abort if there are active child tasks):
var grChildTasks = new GlideRecord('<table where child tasks are>');
grChildTasks.addQuery('parent', current.getUniqueValue());
grChildTasks.addActiveQuery();
grChildTasks.query();
if(grChildTasks.hasNext()){
gs.addInfoMessage('some message to notify the user that the action is aborted');
current.setAbortAction(true);
}
Please Mark Correct AND Helpful. thanks
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2022 12:11 AM
Hi,
Create a before update business rule on the parent table.
Conditions: state changes to closed (according to your requirements)
Script:
var childGR = new GlideRecord('child_table_name');
childGR.addQuery('parent_table_field_name', current.getUniqueValue());
childGR.addQuery('child_field_name_for_state', 'value_for_open');
childGR.query();
if (childGR.hasNext()) {
gs.addErrorMessage('Cannot close parent, open child tasks exists');
current.setAbortAction(true);
}