
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 09:12 AM
Dear All,
I need to notify the Assignment group Manager every week once when the assigned to member of that group is inactive.
I tried using a scheduled job with a script and the events. However, the notifications is not getting triggered at all.
Any suggestions would be of great help.
Thanks
Shan
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 12:41 PM
Try this code. Now the event and notification should be on group table
var grGroup = new GlideRecord('sys_user_group');
grGroup.addQuery("manager.active",true);
grGroup.addQuery("active",true);
grGroup.query();
while(grGroup.next()){
var arr=[];
var inc= new GlideRecord("incident");
inc.addQuery('assigned_to.active',false);
inc.addQuery('assignment_group',grGroup.getValue('sys_id'));
inc.addQuery('incident_state','NOT IN','6,7');
inc.query();
while(inc.next())
{
arr.push(inc.getValue('number'));
}
if(arr.length>1){
gs.eventQueue("inactiveassigntoevent",grGroup,grGroup.manager.email,arr.join()); //here 4th parameter has comma separated incidents that are assigned to inactive users
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 11:39 AM
Hi Abhi,
Actually, I want to notify the manager with all the incident numbers that were assigned to the inactive user for that assignment group. But can this be achieved writing the notification on the group table?
Because I have written my notification on the incident table and also the event on incident.
I will provide screenshots if required.
Thanks
Shan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 11:59 AM
I would rather write a business rule on user table to check user got inactivated and query all incidents assigned to this user and email to the manager.
if you write script on incident table, there could be multiple users inactive and you wont know, to which manager you have to send the notification
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 12:19 PM
Hi Sanjiv,
This is my business case.
When an "Assigned to" becomes inactive in ServiceNow the assignment group manager will recieve an email containing all incidents that are not in a resolved or closed state and are assign to the user who has been made inactive. This email notification should go out on a weekly basis.
So the BR is after Update on User Table
When to run : Active changes to False
in Script : Query the incidents assigned to the User
Notification: Incident Table
Check Param 1 as in the Event Queue script
Does this sound good or have some changes
Thanks
Shan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 12:35 PM
I believe the tricky part is how will you know which all incidents are belongs to which assignment_group, so you may have to use GlideAggregate first to group the glide query result based upon the assignment_group and then run the gliderecord to collect the related incidents to trigger an email to that particular assignment_group manager.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 12:41 PM
Try this code. Now the event and notification should be on group table
var grGroup = new GlideRecord('sys_user_group');
grGroup.addQuery("manager.active",true);
grGroup.addQuery("active",true);
grGroup.query();
while(grGroup.next()){
var arr=[];
var inc= new GlideRecord("incident");
inc.addQuery('assigned_to.active',false);
inc.addQuery('assignment_group',grGroup.getValue('sys_id'));
inc.addQuery('incident_state','NOT IN','6,7');
inc.query();
while(inc.next())
{
arr.push(inc.getValue('number'));
}
if(arr.length>1){
gs.eventQueue("inactiveassigntoevent",grGroup,grGroup.manager.email,arr.join()); //here 4th parameter has comma separated incidents that are assigned to inactive users
}
}