- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2018 06:18 AM
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"
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2018 06:28 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2020 10:00 PM
Thankyou
Its Working ...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2018 06:32 AM
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