- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2019 01:48 AM
Hi Experts,
Good day!
while closing the parent incident , all child incidents are not getting close automatically . but some are closing .
i have checked ootb business rule "update child incidents" i think its fine .
please help me in this .
Thanks in Advance
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2019 03:09 AM
Hi shwetha,
do note that when parent incidents are closed, it doesn't imply in the closure of child incidents. Child incidents must always be closed by the caller or by the system based on the auto closure property.
Here is the synchronization of parent and child incidents -
you can visit this link for more info - https://docs.servicenow.com/bundle/madrid-it-service-management/page/product/incident-management/con...
Hope this helps.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2019 01:53 AM
Hi Shweta,
Can you check the log statements any error while closing incident.
there could be some case that incident cannot be closed because of some validation
add log statements in the out of box business rule
the out of box business rule will mark child incident resolved only when parent incident state changes to RESOLVED
Did you check whether the parent incident is getting closed with a RESOLVED state?
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2019 02:14 AM
Hi Ankur,
condition: before update
updateChildIncidents();
function updateChildIncidents() {
if (current.state.changesTo(IncidentState.RESOLVED) || (current.state == IncidentState.RESOLVED && current.child_incidents.changes()))
resolveChildIncidents();
else {
updateChildren('comments', gs.getMessage('Comment copied from Parent Incident'));
updateChildren('work_notes', gs.getMessage('Work note copied from Parent Incident'));
}
}
function updateChildren(fieldName, msg) {
var rec = new GlideRecord("incident");
rec.addQuery("parent_incident", current.sys_id);
rec.addQuery("state", "!=", IncidentState.RESOLVED);
rec.addActiveQuery();
rec.query();
while (rec.next()) {
var fieldRawValue = current.getValue(fieldName) + '';
var fieldValue = fieldRawValue.trim();
if (!fieldValue || fieldValue.length <= 0)
return;
if (fieldRawValue.indexOf(msg) == 0)
rec[fieldName] = fieldRawValue;
else
rec[fieldName] = msg + ": " + fieldRawValue;
rec.update();
}
}
//
// Resolve active, unresolved incidents that are children of the current incident
//
function resolveChildIncidents() {
//check if update is valid or aborted before updating child incidents
if(current.isActionAborted())
return;
var incident = new GlideRecord("incident");
incident.addActiveQuery();
incident.addQuery("parent_incident", current.sys_id);
incident.addQuery("state", "!=", IncidentState.RESOLVED);
incident.query();
var msg = "";
while (incident.next()) {
gs.print("Incident " + incident.number + ' resolved based on resolution of Parent Incident ' + current.number);
incident.state = IncidentState.RESOLVED;
if (incident.close_notes.nil()) {
msg = gs.getMessage('{0} copied from Parent Incident', current.close_notes.getLabel());
if (current.close_notes.toString().indexOf(msg) == 0)
incident.close_notes = current.close_notes;
else
incident.close_notes = msg + ": " + current.close_notes;
}
incident.close_code = current.close_code;
msg = gs.getMessage("Resolved based on resolution of Parent Incident.");
if (current.comments.toString().indexOf(msg) == 0)
incident.comments = current.comments;
else
incident.comments = msg + " " + current.comments;
incident.work_notes = current.work_notes;
incident.update();
}
}
This is the "update child incident" business rule script .where to check log errors.
Thanks
Shweta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2019 02:37 AM
Hi Shweta,
Is your parent incident getting state changed to Resolved?
Also are your few child incidents already in resolved state? if yes then those won't get updated
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2022 08:30 AM
Hi Ankur,
I too tried this one...But I was unable to close the child incidents while closing the parent incident. Could you tell me the path.. I am trying the correct script itself.. I don't know why it was not implemented there..
Thanks,
Lakshmi