- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 03:09 AM
Hi Everyone,
During some testing for ITSM processes I have noticed that the "Update Child Incidents" business rule is no longer working for Comment/worknote update nor for closure,
The rule appears to still be in it's original state and I canno't see any other rules that would be causing this to abort,
Does anybody have any tips on how I can troubleshoot this to get the rule working again?
Many Thanks
Ben,
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2022 02:58 AM
So yes.... The OOTB rule does work, looks like our initial (or one of the many other ) partners we used setup the incident form wrong... I've now added the correct Table collumn fields to the incident form and all is well with the world!
Apologies for wasting your time but your answers did help me to troubleshoot the problem so it did help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 02:37 AM
Hello
Below is the condition of this OOB Business rule "Update Child Incidents"
condition - current.isValidRecord() && (current.state.changesTo(IncidentState.RESOLVED) || current.comments.changes() || current.work_notes.changes()) && (current.child_incidents > 0)
This Business rule will only run if you have child incidents on Incident and then you update the comments/work notes as per the condition mentioned in the BR.
Please apply logs in the BR and deactivate all the custom BR's as well so that you troubleshoot the issue much faster.
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2022 01:23 AM
Hi
Here is the 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();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2022 01:34 AM
Hello,
Please apply logs in this script and see if your BR is triggering or not, make sure you have child incident under related list of Incident when you update the work notes/comments.
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2022 05:33 AM
Hi,
Do you have any child Incident present for the Incident record you are validating?
One important point to note is try checking if below line of code is being used in other Business Rule which may be colliding with this Business Rule and stopping the comment and Work notes to get copied to child Incidents.
setWorkflow(false);
Navigate to Business Rule and put a filter as shown below and see if there is anything present.
If it is present then try deactivating that Business rule and check the functionality again:
Have tested the script and works fine for me.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke