+ Start a Discussion

Apex scheduler


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


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() {

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




Imran MohammedImran Mohammed

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


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

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