- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 10:55 AM
I am looking at the OOB business rule "SNC - ITIL - Close Related" on the incident table. My need is that when an incident is closed, it NOT close child Incident Tasks. I'm not sure how to tell this script to ignore child INC Tasks though. Any help is appreciated! Thank you.
When: After; Insert; Update
Condition: current.isValidRecord()
Script:
//
// Close any child incidents
//
if (current.active.changesTo(false)) {
closeRelatedTasks(current);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 11:36 AM
You are correct on the first part.
Deactivate the OOB business rule on incident table and create a copy of it.
Modify its code as given (Code is taken from the related global business rule)
if (current.active.changesTo(false)) {
closeIncident(current);
}
function closeIncident(me) {
var incident = new GlideRecord('incident');
if (incident.isValidField('parent_incident'))
incident.addQuery('parent_incident', me.sys_id);
else if(incident.isValidField('parent'))
incident.addQuery('parent', me.sys_id);
else
return;
incident.addActiveQuery();
incident.query();
while (incident.next()) {
var msg = gs.getMessage("Incident '{0}' closed based on closure of task '{1}'", [incident.number, me.number]);
gs.print(msg);
incident.incident_state.setValue(IncidentState.CLOSED);
incident.active.setValue(false);
incident.comments = msg;
var notes = incident.close_notes.getDisplayValue();
notes = notes + '\n' + msg + '\n\n' + me.close_notes;
incident.close_notes.setValue(notes);
incident.close_code.setValue(me.close_code);
incident.update();
}
}
//Sorry script not formatted
Thanks
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 11:05 AM
Have you tried commenting the closeRelatedTasks(current);?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 11:06 AM
Hi Shane,
You need to just deactivate the business rule on incident table and it wont close child incidents when the parent incident is closed.
Thanks
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 11:09 AM
Alikutty,
I only want it not to close Incident Task [incident_task] tickets. It should continue to close child incidents and any other task type that may be related. Thank you for your help.
Shane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 11:19 AM
The business rule on the incident table calls the function "closeRelatedTasks()" which is present in the global table BR(SNC - ITIL - Close Related). You should not modify its code as it is used be other tables.
I suggest you copy the code from the global table BR (function closeIncident()) and modify it to remove incident_task table from the query. Please try and let me know.
Thanks
PS: Hit like, Helpful or Correct depending on the impact of the response