0

I am dealing with two objects: Accounts and Donor Programs.

Accts and DPs have a lookup relationship via the Accts.[Donor Program] field. Accts.[Donor Program] field populates with 'Partner' if a donor donates a certain amount.

I have a scheduled triggered flow that loops through all 'partner' accounts (low-level donors). Then, it updates the "roll-up summaries" to the Partners Donors Programs record on the DP object.

Because the flow is looping through a big set of data, it has exceeded the number of iterations.

enter image description here enter image description here enter image description here

In attempts to resolve this, I have tried the using event platform suggested in this post. and also the DSLR -- but so far no luck.

How to bypass the number of iterations exceeded error as mentioned in the knowledge article:

  • Reduce the total number of records being processed. Process the records in multiple batches.
  • Keep your own counter using a number variable and increment it every loop, exiting the loop when you're about to hit a limit.
  • Consider adding a screen or wait element before looping through next batch of records.
  • Check for alternatives using Apex code.

See my previous post for additional info: Trigger to Count Number of Accounts to Custom Object Field

4
  • Hi, @DragonBallz, since the quantity of records is large, I would recommend you use an imperative approach with Apex. If you have more than 2.000 records to loop through, a flow may not be the best option. Commented Jun 14, 2023 at 21:37
  • Hi! Thank you for responding - Would you have any sample codes? I tried on a different post - trigger AcctUpdateDonorProgram on Account (after update){ List<Donor_Programs__c> partnersDonorProgramUpdate = new List<Donor_Programs__c>(); for(Account newAccts : Trigger.new){ if (newAccts.Donor_Program__c == 'Partners'){ Donor_Programs__c dp = new Donor_Programs__c(); dp.Total_Members__c += 1; partnersDonorProgramUpdate.add(dp); } } update partnersDonorProgramUpdate; } Commented Jun 21, 2023 at 12:38
  • And I am getting this error: "Invalid loop variable type expected Donor_Programs__c was Account" I am not understanding exactly how object-oriented language work (still learning - any guidance on this would be super helpful). Thanks! Commented Jun 21, 2023 at 12:39
  • Hi, @DragonBallz. You cannot use update in that context, because you are instantiating a new Donor_Programs__c, adding it to the partnersDonorProgramUpdate, but those new Donor_Programs__c do not exist in the database. Also "dp.Total_Members__c += 1" is not correct: On every iteration you create a new instance of Donor_Programs__c, each instance is going to be a record in the system, with Total_Members__c = 1. Commented Jun 22, 2023 at 0:15

0

You must log in to answer this question.

Browse other questions tagged .