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
PAX AdminPAX Admin 

Any way to bulkify a flow trigger?

I am part of the flow trigger pilot.

I have a custom object that tracks parts on a bill of materials (product parts). I have another object that tracks a simple production forecast for the products (MRP Forecast) - I have built a flow trigger that evaluates the MRP forecast and creates individual requirements records on a 3rd custom object that is Master Detail to the forecast object for each product on the bill of materials for the product specified in the forecast. (Bills of Material can be anywhere from 1 to 200 part numbers)

It works perfectly if I add or edit a forecast in the native salesforce interface - but we have hundreds of products, and each product needs a separate forecast for each month - so I need to be able to upload my forecast records en mass.

I tried an upload of 30 forecast records and it failed on the record insert: "common.exception.ApiException: record limit reached. cannot submit more than 200 records into this call".

Is there anyway I can "bulkify" the flow so that it collects multiple requests and handles them more elegantly?

Thanks!
-R
AmitAmit (Salesforce Developers) 
Hello,

You can use bulk API option to load data.
Please refer following link for more information ;

https://help.salesforce.com/HTViewHelpDoc?id=loader_configuring_bulk_api.htm&language=en_US

https://help.salesforce.com/help/pdfs/en/salesforce_data_loader.pdf

https://developer.salesforce.com/page/Loading_Large_Data_Sets_with_the_Force.com_Bulk_API

https://help.salesforce.com/HTViewHelpDoc?id=loader_content.htm&language=en_US

Thanks,

Amit Bhardwaj
PAX AdminPAX Admin
Hi Amit,

Thank you for your reply.  However, initially loading the data is not my problem.  I am very comfortable with the dataloader, and my org does not load enough data to be eligible to turn on the bulk API option.  

My problem is that my flow errors out after I have uploaded my forecast data when it is trying to create all the requirements.

The full debug log that shows that it started 31 instances of the flow when I uploaded 31 records and that is what seems to have caused it to fail. and that is what I am trying to consolidate.

Thanks,
Rebecca

James Allen 4James Allen 4
Is it failing because you are trying to insert more than 200 requirements for a single request?  Can you limit your loop to less than two hundred and insert into seperate "batches" of sObject variables?
PAX AdminPAX Admin
It's possible that is the cause of the failure. I'll have to check to see if there are any BOMs in my test set with > 200 parts.  It's probably good error handling to build in to the process regardless - even if there aren't now, there could be down the road.  I'm not sure how to separate or limit the sobject collection to 200 records, though. :-/. I'll see what I can figure out ... Thanks! — Sent from Mailbox
PAX AdminPAX Admin
Nope - turns out none of the BOMs have more than 67 parts - so it really is alll of the requests being submitted at the same time. Blerg.
James Allen 4James Allen 4
Yeah I hove come accross a very simual issue where a "sync" batch process was triggering my flow.  Got a different error but same idea.  I was able to modify the workflow criteria and add the logic into the flow.  But would still like to know if there is any plans for bulkifying trigger flows. 

caused by element : FlowRecordLookup.Lookup_Account

caused by: Too many SOQL queries: 101

Here is a good group to possibly ask the question if you are not already follwing it.

https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F9300000001rzc&fromEmail=1 (https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F9300000001rzc&fromEmail=1)

PAX AdminPAX Admin
Thanks James, I actually posted my question there first, but i figured I'd cover all the bases. :-)  What was the workaround that you figured out?
Lloyd SilverLloyd Silver
Running into this issue as well which greatly limits the usefullness of flow triggers. It really needs to be able to handle bulk soql queries.
Lloyd SilverLloyd Silver
any update on this?
PAX AdminPAX Admin
Not that I found. For this specific issue, I just went ahead and had a trigger built. I hope something will come out soon to help deal with limits better.
FredrickUNFredrickUN
Hi,

As a work around have you tried lowering the batch size in the data loader to say 5  or even 1? 
jwalshjwalsh
Having a similar problem here; my flow is very simple and concise in the context of a single record; it is executed by a flow trigger during a bulk operation, which fails with too many queries.  Is there any way to get the flow trigger to batch triggering records into an sObjectCollection or something of that nature?
Anne MooreAnne Moore
Hello!  I was running into this issue as well, hitting the too many soql queries issue.  I took FredrickUN's advice and changed the batch size to 5 - THIS WORKED!  thanks, Fredrick!
Clyde4Clyde4
I believe this issue is now resolved - that Salesforce added bulkification to flows:
https://help.salesforce.com/apex/HTViewHelpDoc?id=vpm_admin_bulkification.htm&language=en_US