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
John DinkelooJohn Dinkeloo 

Number of iterations exceeded

I'm writing a flow to query a custom object and assign new values to update to the User object and I keep getting an error that says "number of iterations exceeded". I made sure to put my lookup and update outside of the loop but it doesn't seem to matter. The initial lookup returns about 1800 records but if I limit the lookup to 40 or so records, it does seem to work. Is there anyway I can modify the flow so it doesn't throw the iteration error? A partial error log and a screencap of my flow are below. Thanks!
###
Error element Flag_Deposit_User_Checkbox_for_Single_User_Record (FlowAssignment).
Number of iterations exceeded

This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.

Flow Details
Flow Name: Check_Deposit_Users_Box_Flow_2
Type: Flow
Version: 5
Status: Active

Flow Interview Details
Interview Label: Check Deposit Users Box Flow 2 4/6/2017 6:11 AM
Current User: John Dinkeloo (005G0000001sTS5)
Start time: 4/6/2017 6:11 AM
Duration: 2 seconds

How the Interview Started
John Dinkeloo (005G0000001sTS5) started the flow interview.

FAST LOOKUP: Find_all_Account_Owners_with_User_Account
Find all LiveOak__Account_Owner__c records where:
LiveOak__User__c Is null false
Assign those records to {!coll_AccountOwnerWithUser}.
Save these field values in the variable: LiveOak__User__c, Id
Result
Successfully found records.

LOOP: Loop_Thru_Account_Owner_Records
Loop Through: [a2AG000000hAbrnMAC,a2AG000000hAbs2MAC,a2AG000000hAbsbMAC,a2AG000000hAbsgMAC,a2AG000000hAbslMAC,a2AG000000hAbtA (I had to edit out most of the 1800 records returned here because I was exceeding the character limit)]
Iteration: 0
Current value of {!single_AccountOwner}: a2AG000000hAbrnMAC

ASSIGNMENT: Assign_ID_to_Single_User_Record
{!single_UserRecord.Id} Equals {!single_AccountOwner.LiveOak__User__c}
Result
{!single_UserRecord.Id} = "005G0000008xVeWIAU"

ASSIGNMENT: Flag_Deposit_User_Checkbox_for_Single_User_Record
{!single_UserRecord.IsDepositUser__c} Equals true
Result
{!single_UserRecord.IsDepositUser__c} = "true"

ASSIGNMENT: Add_single_record_to_Use_collection
{!coll_UserRecords} Add {!single_UserRecord}
Result
{!coll_UserRecords} = "[005G0000008xVeWIAU]"
###
User-added image
NagendraNagendra (Salesforce Developers) 
Hi John,

It seems to be the 'Maximum number of executed elements at runtime' limit that I am hitting (the limit is 2000, see the Salesforce documentation here: https://help.salesforce.com/apex/HTViewHelpDoc?id=vpm_admin_flow_limits.htm).

The reason this limit is hit is that when looping through records, each element in the loop counts as an executed element multiple times (once per record that you loop through).

For example, the simple loop below could process a maximum of 666 records: 
the 3 elements in the loop * 666 = 1998 executed elements 
+ fast lookup element = 1999 executed elements 
+ fast update element = 2000 executed elements - the limit

For more information please check with below link. Thanks,
Nagendra.
Harshala Godse 1Harshala Godse 1
If your flow is an Autolaunched flow, then it’s a simple choice. Use the Pause element, working like magic  and configure it to resume your flow after 0 hours of current date-time.
Please note that pausing the flow makes the rest of the flow run asynchronously in a separate transaction.
https://forcepanda.wordpress.com/2020/02/04/how-to-cheat-flow-limits/comment-page-1/?unapproved=12451&moderation-hash=5450b3bb955c04592e053c4470232d5a#comment-12451