From ede5cdd137e15939f137d03d92b2fee6c22e13e3 Mon Sep 17 00:00:00 2001 From: Suyash More Date: Wed, 13 Nov 2024 17:57:16 +0530 Subject: [PATCH] Added check for summary record size to prevent MathException --- force-app/main/default/classes/CRLP_RollupQueueable.cls | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/force-app/main/default/classes/CRLP_RollupQueueable.cls b/force-app/main/default/classes/CRLP_RollupQueueable.cls index 760f874fa72..c30eb88dbcb 100644 --- a/force-app/main/default/classes/CRLP_RollupQueueable.cls +++ b/force-app/main/default/classes/CRLP_RollupQueueable.cls @@ -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