Ajax (1) Apex Class (12) Apex Trigger (2) Community (2) Home Page (1) HTML (4) Integration (3) JS (7) KB (1) Label (1) Licenses (1) Listing (1) Log (1) OOPs (5) Sharing (1) Static Resource (1) Test Class (3) URI (1) Visualforce (10)

Monday, 20 October 2014

Schedulable

global class scheduledMonthly implements Schedulable {
   
    global void execute(SchedulableContext sc) {
List<User> lstUser=new List<User>();
     for(User obj:[SELECT id,name,lastlogindate,isActive FROM User where lastlogindate<=LAST_N_DAYS:30])
{
 User objNew=obj.id;
 objNew.isActive=false;
 lstUser.add(objNew)
}
if(lstUser!=null && lstUser.size()>0)
{
update lstUser;
}
 
    }
}

No comments:

Post a Comment