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
Charlotte McCCharlotte McC 

Setting scope size on database.executeBatch

Hi folks,

 

I'm trying to limit the batch size on one of my scheduled batch jobs, and adding a scope parameter on my Database.executeBatch doesn't seem to be working.  Here's my code:

 

batchGenerateOriginalCS cCases = new batchGenerateOriginalCS();
       
cCases.query='SELECT Id, Some_other_fields__c From Case where Some_other_fields__c = 'A string' limit 16';

ID batchprocessid = Database.executeBatch(cCases, 15);

 

So as you can see, I'm testing this by limiting my query to 16, but have (tried to) set the scope on my executeBatch to 15. When I run this bad boy, it runs my batchGenerateOriginalCS class as it ought to, but on 16 cases rather than on 15.

 

Any thoughts?

 

Thanks!

Charlotte

Best Answer chosen by Admin (Salesforce Developers) 
BritishBoyinDCBritishBoyinDC

Just to confirm - the scope limits the number of records executed in each batch - so the code above should initiate two execution of the batch - one with 15 cases, and one with one...

 

You are seeing just one execution, with all 16 cases in the single execution of the batch?

All Answers

BritishBoyinDCBritishBoyinDC

Just to confirm - the scope limits the number of records executed in each batch - so the code above should initiate two execution of the batch - one with 15 cases, and one with one...

 

You are seeing just one execution, with all 16 cases in the single execution of the batch?

This was selected as the best answer
Charlotte McCCharlotte McC

Oooh, I see what you're saying - and I see what I did now. Thanks for that. You're dead right - it was 2 executions, one of 15 and one of 1.

 

Thank you! :)