- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019 01:56 AM
Hi Team ,
when user is not using service now Account after 90 Days , the account will be deactivate from service now and also trigger the notification .
so,i was stuck in Scheduled jobs user is deactivate form user table but notification is not trigger .please look in below script .
1.Written Notification
2.Event Registry
var user = new GlideRecord('sys_user');
user.addEncodedQuery("active=true^last_login<=javascript:gs.beginningOfLast90Days()");
//user.addEncodedQuery("active!=false^name=user, test");
user.query();
while(user.next())
{
gs.eventQueue("logout_user_90days",user,user.email);
user.active = 'false';
user.locked_out = 'true';
user.update();
}
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019 02:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019 02:35 AM
Hi ,
I copied and paste you line and run scheduled job user is deactivated from user table but mail is not trigger.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019 02:33 AM
Hi Hari,
It might be happening that user is deactivated first and as event is in queue so its getting triggered late and at that time it will be having Active= false account, so email is not triggered and as per OOB feature recipients are excluded if active feature is disabled.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks & Regards,
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019 02:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019 02:52 AM
Yes He has email address ,and i tied with Notification
3. Are there other conditions set In the notification?== No
See here i don't select any user . but those who are do not using more than 90 days they can only deactivate from user table .
1. is Event Registry
2.is Email Notification

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019 02:56 AM
Hi Haribabu,
If the user is inactive or locked out, they will NOT receive notifications.
https://hi.service-now.com/kb_view.do?sysparm_article=KB0528661
So you can trigger an notification first and then deactive a user. You can do this by first triggeing a event which will fire the notification. In the notification fire another event. Write a script action which will listen to this event and then lock the user in this script action.
Mark the comment as a correct answer and helpful if it answers your question.