Deactivate inactive user who is not login from last 3 month.

Nitin30
Kilo Contributor

A schedule job exists that runs daily at midnight that checks for the last login date of all users with an entitlement role [itil, sn_customerservice_agent, ITBM roles].  If the login date is more than 3 months ago, or if the created date was more than 3 months ago AND last login date is null, remove that user from the groups that are granting them the inherited roles.

Send a notification to any of these groups' manager that they have been removed due to inactivity.  Include the user name, email address, and last login date in this email.

 created the scheduled job  record is delete from group member table but notification is not triggering  the group member. But when i removed the deleteRecord() from the script notification is triggering.  

Please suggest what needs to do for both action will perform at some time gap.

var inactive = GlideRecord("sys_user");
inactive.addEncodedQuery("roles=ITIL^last_login_time<javascript:gs.beginningOfLast3Months()");
inactive.query();
while (inactive.next()) {

var user = GlideRecord("sys_user_grmember");
user.addQuery("user", inactive.sys_id);
user.query();
while (user.next()) {
gs.eventQueue('Testinggroup', user, user.group.manager);
user.deleteRecord();


}
}

Thanks in advanced.