Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

vintotz
Tera Contributor

in your email notification , at Who will receive section verify if Event parm 1 contains recipient is checked

I have checked that check box  before .

 

find_real_file.png

Hi Babu, it seems that @vhudlikar answers below is correct. inactive/lockout users will not be able to received email notification.

you may refer to this link https://community.servicenow.com/community?id=community_question&sys_id=30bb0ba1db9cdbc01dcaf3231f96...

 

https://hi.service-now.com/kb_view.do?sysparm_article=KB0528661

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