- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2017 02:18 AM
when problem ticket closed then related incidents tickets should close automatically, i write below code but that is not working, kindly help me with your suggestions. (function executeRule(current, previous /*null when async*/) { var gr =new GlideRecord('incident'); gr.addQuery('problem_id',current.sys_id); gr.query(); if(gr.next()){ gr.state= '6'; gr.close_code= Solved('Work Around'); gr.close_notes= resolved; gr.update(); } })(current, previous); Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2017 02:40 AM
Hi Divya,
You need to create/modify a after Update Business rule in the Problem ('problem') table with the Conditions and script as per below screenshot. I have tested the code and is working in my instance. Would like to request you to give it a try and let me know.
For your simplicity, I'm providing the code here:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('incident');
gr.addActiveQuery(); //Cross check only active incidents
gr.addQuery('problem_id', current.sys_id);
gr.query();
while(gr.next()){
gr.state = '6';
gr.close_code = 'Solved (Work Around)';
gr.close_notes = 'The incident is Resolved as the Related Problem is Closed/Resolved';
gr.update();
}
gs.addInfoMessage('The Incident'+ gr.number+' is Resolved');
})(current, previous);
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2017 02:40 AM
Hi Divya,
You need to create/modify a after Update Business rule in the Problem ('problem') table with the Conditions and script as per below screenshot. I have tested the code and is working in my instance. Would like to request you to give it a try and let me know.
For your simplicity, I'm providing the code here:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('incident');
gr.addActiveQuery(); //Cross check only active incidents
gr.addQuery('problem_id', current.sys_id);
gr.query();
while(gr.next()){
gr.state = '6';
gr.close_code = 'Solved (Work Around)';
gr.close_notes = 'The incident is Resolved as the Related Problem is Closed/Resolved';
gr.update();
}
gs.addInfoMessage('The Incident'+ gr.number+' is Resolved');
})(current, previous);
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2017 03:00 AM
Thank you Amlan Pal for your response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2017 01:08 PM
Hi Amlan,
Your script works well.....thank you for sharing it. However it appears to be closing all incidents, not just the parent. How can it be tweaked so only the parent Incident is closed?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2017 08:36 AM
Never mind I figured it out. Needed to replace.....
gr.addQuery('problem_id',current.sys_id);
with....
gr.addQuery('sys_id',current.parent);