Join Duard Lynn Davis for an in-depth discussion in this video Basic structure, part of Learning Salesforce.com Development.
- [Instructor] Okay, now we're going to look at something called Batch Apex. And Batch Apex is that ability in Sales Force, to run processes in the background. The reason you would do this is whatever you are trying to accomplish won't work in a single thread. So for example, you may be trying to process a million records. You're limited to fifty thousand. You may need to do two hundred SOQL queries, you're limited to a hundred. So you need to be able to do your query, and then break it up into smaller chunks that can be processed.
So Batch Apex is what provides for that ability. Batch Apex basically has three parts. One is a loader. The loader class basically has the repeat method the thing that you're going to do multiple times. And it has a final method, it's what you're going to do when you finish processing all of your batches. You have a scheduler. This is a scheduled class, we'll look at that in a second. That you're able to schedule this to execute on a specific time frame, every day, every hour type of thing.
And then finally, the optional one, which I call the controller, and this allows me to create a button that I can then put on the object. So I could put this button on the account object and it would allow me to then click the button and automatically schedule the class. So I'm not having to go into the scheduler and try to do that, or go into the d-vo console and run things there. I can truly run my loader class by just clicking a button and letting it run. This is a great debugging tool, it is optional.
But I will go through what it takes to set it up, and how you can use it.
- How Apex works
- Bulkification and triggers
- Systematically debugging your code
- Sets, lists, and maps
- Trigger and trigger handlers
- Batch Apex
- Debugging and logging