Skip to content

Commit

Permalink
Added check for summary record size to prevent MathException
Browse files Browse the repository at this point in the history
  • Loading branch information
salesforce-suyash-more committed Nov 13, 2024
1 parent 0a60a7f commit ede5cdd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion force-app/main/default/classes/CRLP_RollupQueueable.cls
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ public class CRLP_RollupQueueable implements System.Queueable {
if (objType == Account.SObjectType || objType == Contact.SObjectType) {
// If the summary record has more child opportunities and possibly payments than can be handled in
// this queueable (non-async job), remove it from this processing queue
Integer maxOppsToAllow = (MAX_ATTACHED_OPPS_FOR_QUEUABLE / summaryRecords.size());
Integer divisor = summaryRecords.size() > 0 ? summaryRecords.size() : 1;
Integer maxOppsToAllow = (MAX_ATTACHED_OPPS_FOR_QUEUABLE / divisor);
if (includeChildPayments) {
// If there are payment rollups, then assume at least one payment per opp, which effectively cuts
// the max number of records that can be queried in half
Expand Down

0 comments on commit ede5cdd

Please sign in to comment.