Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This Background Script provides administrators with a quick and reliable method to:
+Check whether all child incidents under a parent are closed.
+Automatically close the parent if all children are resolved.
+Ensure consistent closure logic without manual intervention.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(function() {
var parentSysId = 'a83820b58f723300e7e16c7827bdeed2'; // Replace with actual parent incident sys_id
var childIncidents = new GlideRecord('incident');
childIncidents.addQuery('parent_incident', parentSysId);
childIncidents.query();
var allClosed = true;
while (childIncidents.next()) {
if (childIncidents.state != 7) { // 7 = Closed
allClosed = false;
gs.info("Child incident " + childIncidents.number + " is still open.");
}
}
if (allClosed) {
var parent = new GlideRecord('incident');
if (parent.get(parentSysId)) {
parent.state = 7; // Closed
parent.close_code = 'Duplicate'; // Adjust to valid closure code in your instance
parent.close_notes = 'Automatically closed since all child incidents are closed.';
parent.setWorkflow(false); // Prevent triggering BRs/workflows
parent.update();

gs.info("Parent incident [" + parent.number + "] has been closed automatically.");
} else {
gs.warn("Parent incident not found for sys_id: " + parentSysId);
}
} else {
gs.info("Parent not closed because one or more child incidents are still open.");
}
})();
Loading