Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Notify Assignment Group Manager when Assigned to is inactive

Shankar Manohar
Mega Guru

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

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

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
}
}

View solution in original post

14 REPLIES 14

Abhinay Erra
Giga Sage

Please post the code you have. I will edit the code

Shankar Manohar
Mega Guru

Hi Abhinay,

 

Please see my Scheduled Job Script below. Let me know If am doing anything wrong.

 

var grGroup = new GlideRecord('incident');

grGroup.addQuery('assigned_to.active',false);
grGroup.addQuery('assignment_group.manager.active',true);
grGroup.addQuery('assigned_to.active',false);
grGroup.addQuery('incident_stateNOT IN6,7');
grGroup.query();

while(grGroup.next())

{

gs.eventQueue("inactiveassigntoevent",grGroup,grGroup.assignment_group.manager.email);
gs.log('inactive user');

}

 

In my email notification, I am calling the above event I created.

 

Thanks

Shan

Here you go. 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
}
}

 

 

Abhinay Erra
Giga Sage

Here you go. And also make sure your event is registered on incident table and notification is on incident table

var grGroup = new GlideRecord('incident');
grGroup.addQuery('assigned_to.active',false);
grGroup.addQuery('assignment_group.manager.active',true);
grGroup.addQuery('incident_state','NOT IN','6,7');
grGroup.query();
while(grGroup.next())
{
gs.eventQueue("inactiveassigntoevent",grGroup,grGroup.assignment_group.manager.email);
gs.log('inactive user');


}