You need to sign in to do that
Don't have an account?
LaraWasowski
Flow failing when more than 100 records are passed in
I have a flow that is designed to create a new donation for each campaign member (contact) on a campaign. The flow is triggered by a button on the campaign. The flow works fine for low volume, but when I click the button and there are 100+ contacts on the campaign, it fails, with a "too many SOQL queries" error.
I am using FastLookup / FastUpdate / FastCreate, and was under the impression that the flow functionality was by design able to handle large volumes. Advice? Tips?
I am using FastLookup / FastUpdate / FastCreate, and was under the impression that the flow functionality was by design able to handle large volumes. Advice? Tips?
You seem to be using Fast Lookup within Loop element, which would definitely hit your SOQL limit. Would recommend moving the same out of the loop. You could do the following:
- Fetch the Campaign Member Details (For Lead and Contact) in the Fast Lookup (you might need to add generic Fast lookup before the loop).
- Inside the loop add another Decision Box to compare the CovertedContactId and the Contact Id fetched (This is an assumption that you are re-fetching campaign members if lead is converted without opportunity).
- Based on your decision box (inside the loop), directly move to assignment (you should already be having the values in SObject Variable of loop).
Hope this helps.Cheers!!
Gaurav
All Answers
You seem to be using Fast Lookup within Loop element, which would definitely hit your SOQL limit. Would recommend moving the same out of the loop. You could do the following:
- Fetch the Campaign Member Details (For Lead and Contact) in the Fast Lookup (you might need to add generic Fast lookup before the loop).
- Inside the loop add another Decision Box to compare the CovertedContactId and the Contact Id fetched (This is an assumption that you are re-fetching campaign members if lead is converted without opportunity).
- Based on your decision box (inside the loop), directly move to assignment (you should already be having the values in SObject Variable of loop).
Hope this helps.Cheers!!
Gaurav
But now I am up against the "Maximum number of executed elements at run time" limit of 2000. I can do my best to cut down on the operations inside the loop, but does anyone have experience with other ways of getting around this limit if you want to be able to pass in more thank 2000 records into a loop?
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
If you have additional elements inside your loop, the number of records you can process will be reduced accordingly. For example if there were four elements in my example loop, then the flow could only process (2000 - 2) / 4 = 499 records before hitting the limit. I believe this is the limit you're hitting, as you say that it's adding extra elements that is reducing the number of records you can process.
Would recommend, merging your elements wherever possible to ensure you have minimum number of elements to be executed in a single path.
Hope this helps.
Cheers!!
Gaurav
When you are calling a flow from button/process builder and processing records being fetched within a flow, breaking it into batches is not feasible (wasn't albe to achieve that). However, there are two ways to achieve this:
- Try to merge/generalise most of the assignments and decision boxes that you are using. This should reduce your number of executable elements within a flow.
- Break your Flow into two parts
- One segment would process the records and create one set of data.
- Pass that data into an Apex Class, do the further processing there (preferrably the loop part) and return back to Flow with processed information.
Hope this helps.Cheers!!
Gaurav