Prevent closure parent incident when child incident is open#1748
Closed
naveensnow wants to merge 2 commits intoServiceNowDevProgram:mainfrom
Closed
Prevent closure parent incident when child incident is open#1748naveensnow wants to merge 2 commits intoServiceNowDevProgram:mainfrom
naveensnow wants to merge 2 commits intoServiceNowDevProgram:mainfrom
Conversation
WillemZeiler
requested changes
Oct 3, 2025
Contributor
WillemZeiler
left a comment
There was a problem hiding this comment.
Thank you for your contribution. I have added some comments to your code.
Closing this for now. Once you make additional changes, feel free to re-open this Pull Request or create a new one.
...-Side Components/Business Rules/Abort Parent Incident Closure When Child is Open/scriptBR.js
Show resolved
Hide resolved
| (function executeRule(current, previous /*null when async*/ ) { | ||
|
|
||
| // Query for any child incidents related to the current parent incident. | ||
| var childIncidents = new GlideRecord('incident'); |
Contributor
There was a problem hiding this comment.
Consider using a GlideAggregate, it is more efficient (getting the aggregate instead of full records) and getting the count of child incidents is enough to allow or prevent the closure of the parent.
| When: before | ||
| Update: Check this box. | ||
| In the When to run tab, set the Condition field: | ||
| current.state.changesTo(7) || current.state.changesTo(6) || current.state.changesTo(8) |
Contributor
There was a problem hiding this comment.
Just my preference have them count up so 6, 7, 8, and add what 6, 7, 8 are (closed, resolved, canceled (like in line 6 of your code))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description:
Pull Request Checklist
Overview
Code Quality
Repository Structure Compliance
Core ServiceNow APIs/Server-Side Components/Client-Side Components/Modern Development/Integration/Specialized Areas/Documentation
Restrictions