Removing the Parent child relationship when the state of Parent is Resolved
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2016 02:37 AM
Hi,
How to remove the relationship between parent and child when the state of parent is resolved.
Can anyone help with the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2016 02:59 AM
And how would you define a parent, child. is it incident ,problem, change or a CI . How parent is related to child.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2016 03:04 AM
It can be anything. Like incident is parent of problem for example.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2016 03:23 AM
Hi Sanvi,
You could do this with an after business rule on the parent table. The condition will watch for active changes to false or state changes to closed (or whatever)
Build a query for all child records where the parent is the current record.
For each record found, clear the parent field.
Example:
Name: Remove parent problem from child incidents
When: after
Update: true
Insert: true
Advanced: true
Condition: Active | changes to | false
Script:
(function executeRule(current, previous /*null when async*/) {
var inc = new GlideRecord('incident');
inc.addQuery('problem', current.getValue('sys_id'));
inc.query();
while (inc.next()) {
inc.parent = '';
inc.update();
}
})(current, previous);
Business Rules - ServiceNow Wiki
Business Rules Best Practices - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2016 03:35 AM
Hi ctomasi,
Here i want to check when the parent state is resolved all the child incidents for that parent should not be anymore related for that parent.
i.e when the state of parent is resolved the notification should be triggered only to the parent none of the child incidents should receive the notifications.