When the Child incident are closed automatically parent incident should be closed?

arey yaar
Giga Guru

I created a table(Razor) which acts as child to the incident table. When the State in every child record is changed to Closed State,then the parent Incident Table should automatically..close the Incident Ticket..

Note:"i doesn't want to populate the result to the incident,it should automatically close when the child incidents are closed" 

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

You'll want to run an 'After Update' business rule on the 'u_razor' table that looks like this...

Condition: current.active.changesTo(false) && current.parent.sys_class_name == 'incident'

Script:

// Query for associated records related to the same parent
var inc = new GlideRecord('u_razor');
inc.addQuery('parent', current.parent); // Records related to same parent
inc.addQuery('sys_id' '!=', current.sys_id); // Exclude this record
inc.addActiveQuery();
inc.query();
if (!inc.next()) {
    // If there are no other active records associated to the same parent
    // Close the parent
    var parInc = new GlideRecord('incident');
    parInc.get(current.getValue('parent'));
    parInc.state = 7; // Close the incident
    parInc.active = false;
    parInc.update();
}

View solution in original post

6 REPLIES 6

Thankyou 

Mark Stanger

Its Working ... 

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,


We need to create a Business rule on that Razor table. Condition will be whenever states change to Closed.

 

Script:

 

var gr = new GlideRecord('u_razor');

gr.addQuery('parent',current.parent);

gr.addQuery('state','!=','Please put closed state value of razor state field');

gr.query();

if(gr.next())

{

}

else

{

gs.log('Parent Incident Has been Closed','Incident');

}

 

Note: Please test it before using it in production.

 

Thanks,
Ashutosh