+ Start a Discussion
Venkatesh LVenkatesh L 

How to Create a batch class which runs daily with the help of scheduled class and deactivates users whose last login date is greater than 10 days

Subramani_SFDCSubramani_SFDC
List<User> users = [Select LastLoginDate , IsActive, Id From User where LastLoginDate < :Date.today().addDays(-10)];
for(User u : users)
{
	u.IsActive = False;
}
update users;

use the above query in your batch class and create scheduler class and activate the scheduler daily using apex scheduler button