- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 12:29 AM
Hello Community!
I have a need to send notification to the incident assignee when all the incident tasks are closed.
I have searched for some solution and I found this: https://community.servicenow.com/community?id=community_question&sys_id=094c8b65db9cdbc01dcaf3231f96...
I made my own version of this BR:
table: incident_task
after, insert/update, condition: state changes to closed complete
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('incident_task');
gr.addQuery('incident', current.sys_id);
gr.addQuery('state','!=', 3);
gr.query();
if (gr.hasNext()) {
}
else {
gs.eventQueue('incident.task.closed', current, current.incident.number, current.incident.assigned_to);
}
})(current, previous);
My problem is: anytime when I close a task, the notification triggers even though it should only when all tasks are in closed state.
The notification definition itself hasn't got any other trigger condition.
Can someone please help me out?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2022 02:45 AM
Hello Everyone,
for those who interested, finally have the solution, here is the code:
var count = 0;
var gr = new GlideAggregate('incident_task');
gr.addQuery('incident', current.incident);
gr.addQuery('state', '!=', 3);
gr.addAggregate('COUNT');
gr.query();
if (gr.next()) {
count = gr.getAggregate('COUNT');
}
if (count >= 1) {
return;
}
else {
gs.eventQueue('incident.task.closed', current, current.incident.number, current.incident.assigned_to);
}
The problem was in the 3rd line, where I queried in the wrong way, I used current.sys_id instead of current.incident.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 04:51 AM
Its hard to tell what's similar and what's not about the request.
Please state the exact scenario you want the notification to fire.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 04:08 AM
Hello Kendra,
show your script.