Once Parent Incident Status Changes, Child Ticket Status Should Change automatically for all the states
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 03:06 AM
Hello All,
We are getting a conflict in our current scenario as whenever the Parent Incident Status changes to OnHold and On-hold reason is any one of the reasons from the drop-down, the corresponding Child Incident Status is not getting automatically changed to OnHold. Because of this, the SLA is getting breached in our Child Incidents which is very critical.
Can anyone let me know how to fix this asap?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2022 09:20 AM
Hi Musab,
I have configured the new BR Script which you have proposed me but there seems to be one conflict like when I change the Status to OnHold and select OnHold Reason as Awaiting Caller, then the child tickets status is not changing the On Hold Reason to Awaiting Caller. But when I change the Parent Incident Status back to InProgress then the Child Tickets status is also going to In Progress.
And also I would like to keep you informed that there is one OOB Script which I have found as below.
Script:
updateChildIncidents();
function updateChildIncidents() {
if (current.state.changesTo(IncidentState.RESOLVED))
resolveChildIncidents();
else {
var value;
if (current.comments.changes()) {
value = deriveFieldValue('comments', gs.getMessage('Comment copied from Parent Incident'));
if (value && value != "")
executeFlowAction(current, 'comments', value);
}
if (current.work_notes.changes()) {
value = deriveFieldValue('work_notes', gs.getMessage('Work note copied from Parent Incident'));
if (value && value != "")
executeFlowAction(current, 'work_notes', value);
}
}
}
function executeFlowAction (parentIncidentGr, fieldName, value) {
try {
var inputs = {};
inputs['field'] = fieldName; // String
inputs['value'] = value; // String
inputs['parent_incident_gr'] = parentIncidentGr; // GlideRecord of table: incident
sn_fd.FlowAPI.getRunner().action('global.update_child_incidents').inBackground().withInputs(inputs).run();
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
}
function deriveFieldValue(fieldName, msg) {
var fieldRawValue = current.getValue(fieldName) + '';
var fieldValue = fieldRawValue.trim();
if (fieldValue && fieldValue.length > 0) {
if (fieldRawValue.indexOf(msg) == 0)
return (fieldRawValue);
else
return (msg + ": " + fieldRawValue);
}
return;
}
//
// 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.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();
}
}
Can you please suggest here as I need to implement this on priority basis.
Thanks