Child Inc tickets automatically closed when the Parent INC ticket is closed

ar1
Kilo Sage

Hi,

Can anyone please help us on the below requirement.

We want to close all the child INC tickets when the Parent INC ticket state changes to closed.
We wrote one After / update -->  Business rule but some reasons the child ticket state not changing to closed.
and also we want to copy the work notes and parent inc number from parent to child ticket work notes.

 

Script:

 

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

var num = current.number;
var inc = new GlideRecord('incident');
inc.addActiveQuery();
inc.addQuery('parent',current.sys_id);
//inc.orderByDesc('sys_created_on');
inc.query();
while(inc.next())
{
if(inc.incident_state != 7)
{
inc.incident_state = 7;
 if(JSUtil.notNill(current.comments.getJournalEntry(1)))
 {
 inc.comments = num + " : " + current.comments.getJournalEntry(1);
 }
inc.update();
}
}

 

 

Advance Thanks.
})(current, previous);

  

1 ACCEPTED SOLUTION

Hello,

 

The attached notepad contains the filter condition and the complete script just copy paste it:-

 

Please mark my answer as correct.

 

Thanks.

 

View solution in original post

22 REPLIES 22

Can you paste the screenshot of the condition nd code over here, also i think as per OOB the child gets resolved when parent changes to resolved and the resolved state value is 6

HI,
Please find the condition below:
current.isValidRecord() && (current.state.changesTo(IncidentState.RESOLVED) || current.comments.changes() || current.work_notes.changes()) && (current.child_incidents > 0)

we're trying to attach the scripts screenshots but it's taking more time to upload it, 
Thanks.

Hello 

Can you try to change the incident state to resolved and see if the child Incident is getting resolved

Hi, 

yes, it’s working fine if we change the incident state to resolved then child incident state also changing to resolved. But if we change to closed then child incident state is not changing to closed!!!

Yeah right that is because the OOB design is that a user will resolve the Incident and then after certain days it will autoclose. There is a business rule which controls after how many days it will get closed. This is because a normal itil user will not be able to see the closed state in OOB design

 

Business rule:- Incident autoclose

 

You can also define after how many days you want the Incident to autoclose using the below property

 

glide.ui.autoclose.time

 

Please mark answer correct/helpful based on Impact.