anusha(salesforce developer)

Thursday 15 September 2016

Apex Scheduler

Apex Scheduler

To schedule an Apex class to run at regular intervals, first write an Apex class that implements the Salesforce-provided interface Schedulable.
The scheduler runs as system: all classes are executed, whether the user has permission to execute the class or not. For more information on setting class permissions, see “Apex Class Security Overview” in the Salesforce online help.
To monitor or stop the execution of a scheduled Apex job using the Salesforce user interface, go to Setup -->Monitoring --> Scheduled Jobs. For more information, see “Monitoring Scheduled Jobs” in the Salesforce online help.
The Schedulable interface contains one method that must be implemented, execute.
global void execute(SchedulableContext sc){}
Example:
global class scheduledAccountUpdate implements Schedulable {
    global void execute(SchedulableContext SC) {
        AccountUpdate acc = new AccountUpdate('Description','Updated Account');
    }
}


To get details about AccountUpdate Class go to http://www.infallibletechie.com/2012/05/batch-apex.html
Go to Setup à Develop à Apex Classes and then click ‘Schedule Apex’ button.


            Figure clearly explains how to schedule Batch Apex. The frequency may be set to Weekly or Monthly. Start and End dates are important. Preferred Start Time is also important. The job will be sent to Apex Job queue. The preferred Start Time won’t be the exact time because it depends upon the job queue. The job will be executed after other jobs in the job queue have been executed.

No comments:

Post a Comment