function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amn12345Amn12345 

Batch Apex : Can we pass record number to scope object?

Hi,

 

When we call Batch apex using Query in developer console, Can we specify number of record which we need to process at a time after the query?

 

For eg:

 

Id batchInstant = executeBatch(new BatchClass(Select id, Name from Account), 200);

 

In above syntax, 200 represents batch size of 200 So SF will chuncks number of records in 200 records batch.

My question is, if there are 5000 records can we pass directly at 200 place in the above query?

 

Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
MagulanDuraipandianMagulanDuraipandian

https://sites.google.com/site/infallibletechie/how-to-limit-number-of-records-to-be-processed-per-transaction-in-batch-apex

 

It will take 2000 not 200.

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

SFDC Blog

SFDC Site

If this post is your solution, kindly mark this as the solution and give Kudos.

All Answers

MagulanDuraipandianMagulanDuraipandian

Yes. But the maximum value is 2000 only.

 

Each execution of a batch Apex job is considered a discrete transaction. For example, a batch Apex job that contains 1,000 records and is executed without the optional scopeparameter fromDatabase.executeBatchis considered five transactions of 200 records each. The Apex governor limits are reset for each transaction. If the first transaction succeeds but the second fails, the database updates made in the first transaction are not rolled back.

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

SFDC Blog

SFDC Site

If this post is your solution, kindly mark this as the solution and give Kudos.

Amn12345Amn12345

Hey Thanks Magu.

 

What if i pass 5000 records. It will devide them in chuncks of 2000 records or again it will execute in 200 records batch's ?

MagulanDuraipandianMagulanDuraipandian

https://sites.google.com/site/infallibletechie/how-to-limit-number-of-records-to-be-processed-per-transaction-in-batch-apex

 

It will take 2000 not 200.

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

SFDC Blog

SFDC Site

If this post is your solution, kindly mark this as the solution and give Kudos.

This was selected as the best answer