- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2022 03:52 AM
There is the 'Update Child Incidents' business rule what is being triggered when parent incident get comments, work notes or changes status to resolved.
But if child incident is for example suspended status t won't resolve the child as it is against the state flow.
current script looks like this:
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.isValidField("close_notes") && 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;
}
if(incident.isValidField("close_code"))
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();
}
}
I have tried to add
if (current.incident_state.changesTo(6) && (incident.incident_state = 24))
incident.incident_state = 5;
else if (current.incident_state.changesTo(16) && (incident.incident_state = 24))
incident.incident_state = 5;
incident.update();
just to try to make it work with one extra suspended state, but is still failing. Could you advise how it could be modified, that regardless of the status of the child incident, the incident will be resolved if parent is resolved?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2022 04:35 AM
If it is against the state flow, it will not work. The solution here would be to write a BR on resolve which will check if any child incident is in suspend state and change its state to assigned to so valid state. ( the order should be less that this BR)
Once that is done, this BR will automatically change it to resolved.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2022 04:35 AM
If it is against the state flow, it will not work. The solution here would be to write a BR on resolve which will check if any child incident is in suspend state and change its state to assigned to so valid state. ( the order should be less that this BR)
Once that is done, this BR will automatically change it to resolved.
Raghav
MVP 2023