Notification from Incident Table, when all incident tasks are closed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 02:32 PM
My goal is to send an Notification from the Incident Table when All Incident Tasks are closed. The Notification and Event are on the Incident Table and the Business Rule is on the Incident_Task table. I also need to include all task numbers under the Incident within the notification.
I have written an Event to trigger when any Incident Task is closed. Then the Business Rule (Script below) which calls the Notification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 02:37 PM
Hi @Kendra F,
Are all incident tasks created when the incident is created? Or they are created at later stages or manuall?
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 02:39 PM
They are created later manually.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 02:51 PM - edited 03-07-2025 02:53 PM
You can use the following script (Script 1). However, there could be a use case when you have for example 2 incident tasks, when both would be closed, then the notification would be sent out. Later if you create an additional Incident Task, and it gets closed, this would trigger another notification.
What would be the best, if you have a defined number of incident task which gets created within incident lifecycle you can try script 2. and adjust the number of incident tasks
SCRIPT 1:
var count = 0;
var gr = new GlideAggregate('incident_task');
gr.addEncodedQuery("incident=" + current.incident + "^active=true")
gr.addAggregate('COUNT');
gr.query();
if (gr.next()) {
count = parseInt(gr.getAggregate('COUNT'));
}
if (count == 0) {
gs.eventQueue('incident.incident_tasks.closed', current, current.sys_id, current.assigned_to);
}
SCRIPT 2:
var count = 0;
var gr = new GlideAggregate('incident_task');
gr.addEncodedQuery("incident=" + current.incident + "^active=false")
gr.addAggregate('COUNT');
gr.query();
if (gr.next()) {
count = parseInt(gr.getAggregate('COUNT'));
}
if (count == 4) { //Replace 4 with the defined number of incident tasks
gs.eventQueue('incident.incident_tasks.closed', current, current.sys_id, current.assigned_to);
}
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 03:20 PM
Thanks for helping! Still having issues.
I used #1 example above, then I created Incident with two Incident Tasks. Closed one Task and it produced two notifications even though there is one task still open. I had tried something very similar to what you suggested before and couldn't get it to work.
Also, how would i list the numbers of the Tasks associated on the Incident?