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 03:46 AM
Hi Sanvi,
Thank you for the clarification. The script is very similar. Just change the condition to "State | is | Resolved". To prevent triggering, add inc.setWorkflow(false);.
I will assume you already have a notification set up for when the parent (in this case problem) becomes resolved. If not, refer here: Email Notifications - ServiceNow Wiki
Name: Remove parent problem from child incidents
Table: Problem
When: after
Update: true
Insert: true
Advanced: true
Condition: State | is | Resolved
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.setWorkflow(false);
inc.update();
}
})(current, previous);