How to pass user in eventQueue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-29-2023 05:26 AM
Hi Team,
I am trying to schedule a job that remove users groups and roles who have not logged in for last 3 months.
But while working on notification im stuck as its new for me.
I have gave admin directly in user field of notification in this case its sending notification for admin but not for specific users for whom role/group is deleted.
Kindly correct me.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-29-2023 05:34 AM
Hi,
Can you please share your script as a text/code, it is diffucult to suggest changes in screenshot.
Also I see you are setting user record active=false;
System does not send notifications to inactive users, user should be active in order to receive email notifications.
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-29-2023 06:02 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-29-2023 06:15 AM - edited ā11-29-2023 07:33 AM
Hi,
Please try below:
var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('active=true^last_loginRELATIVELT@dayofweek@ago@90'); // this gets all the users who are active and last logged in 3 months(90) ago
gr.query();
while (gr.next()) {
//Moving bewlo two lines to end of script
//gr.active = 'false';
//gr.update();
var gr2 = new GlideRecord('sys_user_grmember');
gr2.addQuery('user', gr.sys_id);
gr2.query();
gr2.deleteMultiple(); //deletes the user from the groups
var gr1 = new GlideRecord('sys_user_has_role');
gr1.addQuery('user', gr.sys_id);
gr1.query();
gr1.deleteMultiple(); // deletes all the roles the user have
gs.eventQueue('notify user',gr, gr.email , gr.name);
Once your trigger event make user record inactive , i would suggest this is not required
gr.active = 'false';
gr.update();
}
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-29-2023 07:33 AM
@Preethi26 did you check this script?
Thanks
Anil Lande