1

I've got an autolaunched flow which run whenever a Custom object adoption is created. The flow then links the adoption to a school, first by searching for one, and creating one if it doesn't already exist.

This works fine when doing one at a time, but when I upload a list of adoptions all at the same school I am getting a duplicate error. When the second adoption goes through the flow, it does a lookup for the school, but finds nothing, so it tries to create a duplicate.

It seems like when doing an insert in bulk all the records that are created from a flow are created at once at the end. Is there any way to get around this that still uses visual flow?

1
  • 1
    pretty sure the only way to 'handle' this is to set the batch size to 1 when doing your upload.
    – gorav
    Feb 14, 2018 at 11:31

1 Answer 1

2

When you do a bulk insert, every 200 records is considered one "transaction". This means your automation needs to be built around dealing with multiple records at one time.

The flow creator, like Apex code, needs to be "bulkified". Basically it will involve changing your flow to utilize collections and loops.

How Does Flow Bulkification Work? Interview operations are bulkified only when they execute the same element. That means that the interviews must all be associated with the same flow. Available in: both Salesforce Classic and Lightning Experience Available in: Enterprise, Performance, Unlimited, and Developer Editions When multiple interviews for the same flow run in one transaction, each interview runs until it reaches a bulkifiable element. Salesforce takes all the interviews that stopped at the same element and intelligently executes those operations together. If other interviews are at a different element, Salesforce then intelligently executes those operations together. Salesforce repeats this process until all the interviews finish.

If, despite the bulkification, any interview hits a governor limit, all the interviews in the transaction fail. Any operations that the interviews performed are rolled back, and the transaction doesn’t try to perform the operations again.

See this link for more info: https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_admin_bulkification.htm

1
  • So I have several flows that utilize collections and loops, but in all of those examples I am doing a fast lookup to create the collection to loop through. In this particular case I'm not sure how to do that. The problem here is the interviews aren't communicating with one another. Feb 9, 2018 at 23:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .