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

Hi Saurav,
Many thanks for the response.
As you mentioned it's correct.
But our requirement is, In some cases user will directly closed the inc ticket instead of resolved, so during this we want to closed the child INC as well.
Can we modify the existing Business rule to set the child INC state to closed without effecting the current process.

Advance thanks.

Hello,

 

Yes you can modify the OOB business rule generally not advisable and add the condition that it should also run when state changes to closed similar to resolve and then how for resolve a function is defined you need to do the same.

 

Please mark answer correct/helpful based on Impact.

 

Hi Saurav,
Many thanks for your continuous support.
Since we're new to modifying  the OOB script,
Could you please help us, where we need to add the closed logic in the script without effecting the current process.

We tried to attach the script from last few hours and some reasons it's taking more and more time to upload the scripts screenshots.

Could you please share your personal id, so that we can send the code.

Many thanks for the support.

Hello,

 

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

 

Please mark my answer as correct.

 

Thanks.

 

Hello,

 

If my answer helped you can you also mark it as correct