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
Jan MattesonJan Matteson 

Flow from process builder errors on data load - Too many soql queries

I have a simple flow that changes the owner on an opportunity to the account owner upon creation. It is called from process builder when the opportunity is created.  Three simple steps:
1. Lookup Opportunity (to get account id)
2. Lookup Account (to get owner)
3. Update Opportunity (with owner)

It works fine when adding opportunities from the UI or in small batches but any large load causes too many SOQL queries.  My opportunities are coming from another system so I have to be able to handle volume.  I have no loops in the flow and can't batch because it is triggered by process builder.
Any ideas would be appreciated.
James LoghryJames Loghry
My guess is there are Apex triggers on the opportunity that are getting fired when you update them via the flow, can you check?
Jan MattesonJan Matteson
There are no triggers on the object.

Looking at the debug log it is obvious that salesforce is looking at the entire data load as one batch - first test is testing WF criteria on all, then it does the flow interview on all, and then it does the action on all.  Unfortunately, I don't know how to bulkify the flow.  When I have flows with loops, I add to a collection and do the dml action outside the loop.  In this case, I just have three steps that need to be taken on every record but I don't know how to gather them into a collection before passing to the flow.   
Anne MooreAnne Moore
Hi Jan!  I have run into this before also using process builder.  Depending on your criteria, try using the "Do you want to execute the actions only when specified changes are made to the record?" checkbox when setting up the criteria for action.
Barb LaMantiaBarb LaMantia
Jan,

Where you able to find a solution to your problem? I am running into the exact problem. I am just trying the run the same three steps as you are but can get it to work on batches.
 
Jan MattesonJan Matteson
It is a known bug.  Until they fix it, I had to revert to trigger.
Here is the idea to follow:
https://success.salesforce.com/ideaView?id=08730000000DhBlAAK