Wednesday, December 7, 2011

How to build a scheduled Apex Class:

Topic in Detail: As we have discussed how to schedule a apex class and we need to assign a apex class in the schedule apex setup. The apex class is not same as our general apex class. We have to implement some syntactical changes in our apex class if we want to schedule that.

Note: If we don’t follow this syntax for schedulable apex class then we cannot find our class in the schedulable class options. SalesForce give options to choose apex class only for the classes which follows this syntax.

The syntax is:

global class ScheduledApexController implements Schedulable{

/* Optional Variable Declarations */

global void execute(SchedulableContext ctx){

/* Optional Variable Initialization */

/* Complete Logic */
}
}

We have to make our class as Global by global keyword and implement a schedulable interface. implements is a keyword to apply interfaces, as we know apex is based on java so you get the idea what it is.

Then we have to write a function execute which is also has its access as global and pass the SchedulableContext object as a parameter.

so this way u can change write a schedulable apex class.

For more guidance, reach me at:

http://www.amitgoyal09.blogspot.com
http://www.salesoncloud.blogspot.com
nicsplacement@gmail.com
linkedIn, Twitter, IM by name amitgoyal09

Thanks,
Amit Goyal
Online Trainer and SalesForce Developer
(SalesForce, MCA, BCA,RHCE)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.