Apex Scheduler

Ratings:
(4)
Views:844
Banner-Img
  • Share this blog:

Apex Scheduler in Salesforce

Apex scheduler is helpful to invoke apex classes to run at specific times, first implenent the “schedulable” interface for the class, then specify the schedule using either the schedule apex page in the salesforce user interfaces, or the system schedule method. Note:- Salesforce only adds the process to the queue at the scheduled time actual execution may be delayed based on service availability. We can only have 25 classes scheduled at one time we can evaluate current by viewing the scheduled jobs page. Go to the following path to view the scheduled jobs. Your Name ---> Setup ---> Administration setup ---> Monitoring ---> Schedule Jobs

Aspired to become an Salesforce? Explore the post to discover the know-hows on Salesforce Training Manual.

Implementing the Schedulable Interface:-

To schedule an apex class to run at regular intervals, first write an apex class that implements the interface schedulable (Salesforce Provided) The Schedulable interface contains one method that must be implemented “execute”

EX:- Global void execute (Schedulable Context sc) {
 }

The following example implements the schedulable interface for a class called helloworld EX:- 

Global class schedule helloworld implements schedulable { global void execute
 (schedulable context sc)
 {
 Helloworld hw = new helloworld ( ) ;
 }
 }

To schedulable jobs using the apex scheduler:- Click your Name → setup Apex classes

  • Click on schedule apex button
  • Specify the name of a class that we want to schedule
  • Specify the how often the apex class is run.

For Weekly → Specify one or more days of the week the job is to run ( such as Monday and Wednesday )

For Monthly → Specify either the date the job is to run or the day ( such as second Saturday of every month) Specify the start and end dates for the apex scheduled class. If we specify a single day the job only runs once.

  • Specify a preferred start time. The exact time the job starts depends on what jobs are in the queue at that time.
  • Click “Save” button.

Standard Apex Schedular with Account Creation Class :

global class CreateAccountSchedule implements Schedulable
 {
 global void execute(SchedulableContext SC)
 {
 Account_Creation ac = new Account_Creation();
 ac.Create_Account('Osmania University', '9052');
 }
 }

For indepth understanding of Salesforce click on

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox