when all child tickets are closed then the parent ticket should be closed automatically

Akhil Maan1
Tera Contributor

Hi,

when all child tickets are closed then the parent ticket should be closed automatically

Thanks 

Akhil

3 REPLIES 3

Kalyani Jangam1
Mega Sage
Mega Sage

Hi,

Used Before Update BR with below filter condition

State Changes to Closed

In advance script try below logic

(function executeRule(current, previous /*null when async*/ ) {

var inc = new GlideRecord("incident");
inc.addQuery("parent_incident", current.sys_id); //how many child ticket assigned
inc.addQuery("state", "!=", 6); // Close state value
inc.query();
if (inc.getRowCount() > 0) {

gs.addErrorMessage("There are child ticket who are not yet Closed");
current.setAbortAction(true);
}

})(current, previous);

 

Please let us know if it helpful

Hi Kalyani,

Thank you for your response.

I tried your script but is not working, when I closed the child ticket then the parent ticket is not closed. And, the parent ticket is in the same state, there is no change in the state.

Regards

Akhil

Kalyani Jangam1
Mega Sage
Mega Sage

Hi Akhil

Modified Br like below

When to run=> after Update

Filtered condition - State changes to closed and

parent incident not empty

In advance used below logic

(function executeRule(current, previous /*null when async*/ ) {
gs.addInfoMessage("BR Triggers");
var inc = new GlideRecord('incident');
inc.addQuery('parent_incident', current.parent_incident); // Records related to same parent
inc.addActiveQuery();
inc.query();
if (!inc.next()) {
gs.addInfoMessage("In Child BR-----");
var parInc = new GlideRecord('incident');
parInc.get(current.getValue('parent_incident'));
parInc.state = 7; // Close the incident
parInc.close_code = 'Solved (Permanently)';
parInc.close_notes = "Test Resolution Notes";
parInc.update();
}

 

})(current, previous);

------------------------------------------------------------------------

Please let us know if it is helpful or not