simplifying flow to avoid flow limits - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Nicholas ZuaroNicholas Zuaro 

simplifying flow to avoid flow limits

Hello,
I presently am working on a flow that I'm having a bit of trouble with.
I have two different flows, and I'm only having an issue with the second one, however you have to understand the first one to understand the second one.


Here's a short object structure to understand:
Work Orders (Master)
Work Order Materials (Detail to Work Orders)
________________
Assemblies (Master)
Assembly Components (Detail to Assemblies)
________________
Basically, the first flow is triggered automatically when a Work Order is created for a Machine Assembly.
When  someone is assigned a Work Order, they know what different components they need to build the machine based on the Work Order Materials on each work order.
When a Work Order gets created, the flow looks at the corresponding Assembly record, and adds that Assembly's Assembly Components to the Work Order, as Work Order Materials.
So if the Work Order is to build Item #117, the flow checks the Assembly for Item #117 and finds the matching components. IF an Assembly Component, also happens to have it's own Matching Assembly record, a Work Order is created for that Assembly as well. Basically, by the time this is done, the flow should ideally create about 150 Work Orders. One for each Assembly required toward building this machine. Each Sub-Work Order created by this master work order, will all have a lookup TO the Master Work Order on it.
That's the first flow.
Now the second flow, is a button on the Master Work Order, to take each and every other Work Order, compare it against it's Assemblies/Components, and actually add the components.
The first flow simply created the Work Orders but couldnt create the Work Order Items.
So I made another flow to handle the task and even this flow on it's own can't add all of the components.
First I had it set up wonderfully, however I hit the limitation for Fast Creates in flows. 200 records per Fast Create. So now, to my understanding, the only way to achieve this in one flow is by having multiple different Fast Creates. To avoid that, once the flow is ready to create 200 records, I create the records, then simply clear the variable values and route the flow back to the beginning.
However, NOW the flow blows right past the 2,000 executable elements per flow limitation. 
(There's well over 1,000 Assembly Component records that need to get created as Work Order Material records in this process)
User-added image
I just don't know if there's a more simple configuration for the flow that would help me avoid all of the nonsense. Ooooor any other suggestions for this type of thing.

_______

Other things that might be useful to know:
-The subworkorders being searched for in the Fast Create are only Work Orders that have the Master Work Order field be the ID of the original Work Order and have not already received their Work Order Materials IN FULL (as told by a formula checkbox "WOM_Added_Completely")
-Then for each Work Order within that loop, there is a Fast Lookup for all of the Assembly Components (The ones that haven't already been added as told by a checkbox).
-For each Assembly Component found, we assign some of it's fields to a Work Order Material(WOI in the image), 
-In the aforementioned Assignment element is also a variable that counts up 1 for each record it passes.
-The Next Assignment "Check it" checks off a checkbox for the Assembly Component record being looped through, so that we know that we've done this one already
-Add to Collection assignment adds both the new WOI records to it's respective collection as well as adds all the Assembly Component record updates(the checkboxes) to IT'S respective collection.
-Now comes the decision based on the variable mentioned earlier. If the counter is at 199, we skip straight to the Fast Creates to avoid our Fast Create Limits.
-We update the Assembly Components with their checkboxes,
-We clear all of the collections so that they may be recycled.
And then we start over.

I've tried moving the arrow to just start at the next Fast Lookup, but hit the same issue. Then I tried moving the arrow directly to the first loop but that didn't seem to do much, if anything either.  I am at a loss hear, I don't know what more I can do to stay within my limits.
Any advice?
Any ideas for solving this issue or coming up with Work Arounds?
I'm all about the work arounds.
And hey, if you made it this far..... Thanks for even reading this whole thing!
Sorry it's so long,
and thanks for your help/time.

Stephen PriceStephen Price
Hey Nicholas,

Yay... sounds like you'll hit limits with the Flow.  I'd suggest trying to integrate the flow into a Process Builder process.  You can call Flows from the Process Builder and you can make a process loop.  I think you could creatively get around your limitation by utilizing both processes https://help.salesforce.com/HTViewHelpDoc?id=process_action_flow.htm&language=en_US , but it is definitely a beefy process you are working with.

Another thing to consider since you are reaching the limits for the record create for a flow is to split it into multiple flows which are called as separate actions on the Process Builder.  You'd have to figure out criteria of how to split what is created, but that is a more detailed component that you might have to figure out separately through record type assignment or some sort of differentiating element for the records you create.

-Stephen