- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2024 12:50 AM
HI,
I have one question..
When all the child records are closed, auto close the parent record if the parent record is in state “On Hold”.
Any help will be thankfull.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2024 10:58 AM
Hi @purnendutiw ,
I tried your problem in my PDI and it worked for me please check solution below
Create after business rule on particular table(I take incident table) and add below code
(function executeRule(current, previous /*null when async*/) { // Add your code here gs.log("Current State = " + current.state); if(current.state = 3){ // On Hold state gs.log("Inside if = " + current.state); var parentInc = new GlideRecord('incident'); parentInc.addQuery('state', 3); parentInc.query(); if(parentInc.next()){ gs.log("Inside Parent inc"); var childInc = new GlideRecord('incident'); childInc.addQuery('parent_incident', current.sys_id); childInc.addQuery('state', 7);//close childInc.query(); if(childInc.next()){ gs.log("Inside Child Inc While"); parentInc.state = 7; parentInc.close_code = "Duplicate"; parentInc.close_notes = "test"; parentInc.update(); gs.log("After update"); } } } })(current, previous);
Result
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2024 10:58 AM
Hi @purnendutiw ,
I tried your problem in my PDI and it worked for me please check solution below
Create after business rule on particular table(I take incident table) and add below code
(function executeRule(current, previous /*null when async*/) { // Add your code here gs.log("Current State = " + current.state); if(current.state = 3){ // On Hold state gs.log("Inside if = " + current.state); var parentInc = new GlideRecord('incident'); parentInc.addQuery('state', 3); parentInc.query(); if(parentInc.next()){ gs.log("Inside Parent inc"); var childInc = new GlideRecord('incident'); childInc.addQuery('parent_incident', current.sys_id); childInc.addQuery('state', 7);//close childInc.query(); if(childInc.next()){ gs.log("Inside Child Inc While"); parentInc.state = 7; parentInc.close_code = "Duplicate"; parentInc.close_notes = "test"; parentInc.update(); gs.log("After update"); } } } })(current, previous);
Result
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2024 01:37 PM
This video teaches you how to do what you're asking for in Flow Designer (more or less).
You just need to add a condition somewhere that factors for the parent on hold condition.