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
Zuri LinnZuri Linn 

Help with Batch Apex and governor limits

Hello,

I am new to apex development and need some help with a Batch Apex job, I need to pull the ownerId from a custom object "Forecasting", find all accounts that have that ownerId listed as the account owner, then query all invoices for those accounts and sum the invoice amounts for each month of the year and put the total in a field on the Forecasting detail object, the Forecast detail records are each month of the year.  Busier months could involve hundreds of thousands of invoice records.  Can anyone help me in working through this without hitting any governor limits?
Best Answer chosen by Zuri Linn
Deepali KulshresthaDeepali Kulshrestha
Hi Zuri,

Batch Apex Governor Limits:
1. Methods declared as the future aren’t allowed in the classes that implement Database. batchable Interface.
2. Methods declared as the future can’t be called from Batch Apex class.
3. For sharing recalculation, we recommend that the execute method to delete and then recreate all Apex managed Sharing for the records in the batch.
4. For every 10,000 AsyncApexJob records, Apex created one additional AsyncApexJob record of type Batch Apex works for internal use.
Follow these link also for Governor limits and Scope in Batch Apex:
1. https://www.tutorialkart.com/learn_apex/governor-limits-and-scope-in-batch-apex/
2. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha.