User Deactivate from user table after 90 days

Hari Babu
Mega Expert

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();

}

1 ACCEPTED SOLUTION

reginabautista
Kilo Sage
Try changing the parameter to below gs.eventQueue("logout_user_90days",user,user.sys_id);

View solution in original post

12 REPLIES 12

Hi ,

 

I copied  and paste you line  and run scheduled job user is deactivated from user table but mail is not trigger.  

Viraj Hudlikar
Tera Sage

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.  

reginabautista
Kilo Sage
There's three things you need to check: 1. Does the user has email address? 2. Is the event tied to the notification? 3. Are there other conditions set I nthe notification?

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 

find_real_file.png

find_real_file.png

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.