Closing Incidents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
We need to make a change so that Incidents cannot be closed if they have open incident tasks. We have learned that users are closing incidents before others close out the incident tasks assigned to them. This results in the incident task being closed as incomplete.
Can someone point me in the right direction for where this logic lives so that I can make a change?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
You may need to implement BR on incident table when someone try to resolve incident to check if there is any active incident task. bellow is sample script.
(function executeRule(current, previous /*null when async*/) {
// Query the Incident Task table for any open/active tasks tied to this incident
var taskGr = new GlideRecord('incident_task');
taskGr.addQuery('incident', current.sys_id);
taskGr.addActiveQuery(); // Checks for active = true
taskGr.query();
if (taskGr.hasNext()) {
// Prevent the incident from being closed/resolved
current.setAbortAction(true);
// Display the user-friendly suggestion/warning
gs.addErrorMessage('You cannot close this incident while there are open incident tasks. Please close all related incident tasks before closing the incident.');
}
})(current, previous);
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @sseverance
you can create a Before-Update Business Rule on the incident table. This script queries the incident_task table for any open records linked to the parent Incident and stops the closure process if found.
- Navigate to System Definition > Business Rules and click New.
- Fill out the form with the following details:
- Name: Prevent Incident Closure with Open Tasks
- Table: Incident
- Active: Checked
- Advanced: Checked
- Go to the When to run tab and set the filter conditions:
State changes to Closed ( depending on your business process)
Script:
(function executeRule(current, previous /*null when async*/) {
// Query the incident_task table for tasks related to this incident that are not closed
var task = new GlideRecord('incident_task');
task.addQuery('incident', current.sys_id); // Links to the parent incident
task.addEncodedQuery('stateNOT IN3,4,7');
task.query();
// If open tasks exist, abort the save and show an error message
if (task.hasNext()) {
gs.addErrorMessage('You cannot close this Incident because it has open Incident Tasks. Please close all related tasks first.');
current.setAbortAction(true);
}
})(current, previous);
4.Save and test it