12

Execute Batch Class in APEX

How To Execute Batch Class In Apex?

To execute the batch class, we use the Database.executeBatch() method.

 

Below is an example of code to execute batch class in Apex.

 

// Create object of Batch Class
LeadUpdateBatch lUBatch = new LeadUpdateBatch();
// execute batch with chunk size 200
Database.executeBatch(lUBatch, 200);

Check out the video to understand and know how to write code in order to execute the batch class in Apex.

Salesforce certifications
Next Topic

Need more support?

Get a head start with our FREE study notes!

Learn more and get all the answers you need at zero cost. Improve your skills using our detailed notes prepared by industry experts to help you excel.

Frequently Asked Questions

What is Database.executeBatch in Apex?

Database.executeBatch() is a method that submits a batch Apex class for execution. It returns an ID representing the AsyncApexJob record to monitor and abort the job.

Can we execute the batch class manually?

Yes, a developer can execute batch classes manually using the Developer Console via Anonymous Apex and the Salesforce CLI.

Why do we use batch execution in Salesforce?

Batch execution in Salesforce is used to process large volumes of records that exceed Salesforce's governor limits. This makes it ideal for mass data updates, data migrations, cleanups, bulk email sending, complex calculations, and more.

Book Free15-Minutes Career Counselling