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

Thanks for the response.
if we remove 0 from the code it's working fine. But same script in my PDI it's working fine if we keep the 0 in the script.
Any reasons why we keep 0 in the msg line?

Thanks.

 

Tony Chatfield1
Kilo Patron

Hi, I would suspect that your issue is mandatory field not being populated for the child?
Perhaps try setting fields like that close_code and close_notes either directly or via mapping to the parent.
Also I am not sure that your test of journal entry 1 is valid, or if there is any point trying to check the content of as it will always have a value unless the parent comments were never updated.
testing in a PDI this works
if(current.comments.getJournalEntry(1) != '') {

palanikumar
Mega Sage

Hi,

Do you have any mandatory fields to be filled before closing incident? The OOB BR updates Work Notes, Comments and Close Code from parent. If you have any additional mandatory field for closure then you need to send value to those fields, otherwise the update will get aborted

Thank you,

Palani

Thank you,
Palani