- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 01:14 AM
Hi All,
I am using below code to check the child incident state before closing parent incident , but the code is not working , someone please check and suggest the code changes
i am making the parent incidents state to resolved , instead of abort the state value is setting to resolved
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 01:53 AM
your business rule should be of type Before update
use this script with some minor change
var gr = new GlideRecord('incident');
gr.addQuery('parent_incident', current.sys_id);
gr.addQuery('stateNOT IN6,7');
gr.query();
if (gr.hasNext()) {
gs.addErrorMessage('please close child incidents before clsong parent incident');
current.setAbortAction(true);
current.state = previous.state;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 01:53 AM
your business rule should be of type Before update
use this script with some minor change
var gr = new GlideRecord('incident');
gr.addQuery('parent_incident', current.sys_id);
gr.addQuery('stateNOT IN6,7');
gr.query();
if (gr.hasNext()) {
gs.addErrorMessage('please close child incidents before clsong parent incident');
current.setAbortAction(true);
current.state = previous.state;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 12:15 AM
Hi @Ankur Bawiskar ,
Thank you for your response , the script you suggested is not working , we are getting the error log but incident state is updating to "Resolved"
let me know if any changes required
Regards
Shabbir Shaik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 12:21 AM
share the BR configuration screenshots
did you check logs and see what came?
check which field populated parent? is it parent or parent_incident ?
try this
var gr = new GlideRecord('incident');
gr.addQuery('parent_incident', current.sys_id).addOrCondition('parent', current.sys_id);
gr.addActiveQuery();
gr.query();
if (gr.hasNext()) {
gs.addErrorMessage('please close child incidents before clsong parent incident');
current.setAbortAction(true);
current.state = previous.state;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2025 02:42 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 02:02 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader