+ Start a Discussion
MunmunMunmun 

Apex scheduler

Hi,

Please some one let me know for apex scheduler with sample codeapex

BritishBoyinDCBritishBoyinDC

Assuming it is a batch class called ContactTotals this would make a class available to schedule  via the UI:

 

 

global class bfc_scheduledctotalrefresh implements Schedulable{

global void execute(SchedulableContext sc) {

ContactTotals ctotal = new ContactTotals();
ID batchprocessid = Database.executeBatch(ctotal);
}

public static testMethod void testschedule() {

Test.StartTest();
bfc_scheduledctotalrefresh sh = new bfc_scheduledctotalrefresh();
        String sch = '0 0 23 * * ?';
        system.schedule('Contact Total Update', sch, sh);
Test.stopTest();

}
}

 

 

Imran MohammedImran Mohammed

Just to add up, the class should implement Schedulable interface to be scheduled.

BritishBoyinDCBritishBoyinDC

Ah - thanks Imran - missed that rather crucial first line in my cut and paste - have updated to include the missing first line Imran refers to

MunmunMunmun
Hi, Thanks for solution. Since i m new to SALESFORCE could u kindly let me know,that from begining. that is write simple apex for insert new account, shedule that for 1 hour