Parent ticket should not be allowed to close with open child

Delapan
Tera Contributor

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!!!

1 ACCEPTED SOLUTION

Martin Ivanov
Giga Sage
Giga Sage

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

View solution in original post

2 REPLIES 2

Martin Ivanov
Giga Sage
Giga Sage

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

OlaN
Giga Sage
Giga Sage

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);
}