0

Is is possible to pass multiple records at once to a flow?

I am having a transaction which inserts more records at once. I want to do some processing using Process Builder + Flow (searching for related records mainly and updating them).

I want to do that processing in the flow and I need all records that initiated the insert.

I have tried to create a text variable and pass the record id from process to it for further processing, but it only takes the first record id and then the other ones are seen as null.

Is it possible to send such a collection from Process Builder to auto-launched flow?

  • How are you getting collections(or list of record) at process builder ? – Ankuli Jul 1 at 16:31
0

Process Builder to Flow is "bulkified". This means that records are batched in groups of 200 similar to Apex Triggers. So if you are loading 200 records into Salesforce and they meet the Process Builder criteria they are "batched" when sent to Flow in batches of 200.

BUT, as you will see in the Debug logs these batches show up as size = 1. There is no variable like Trigger.New for Flows so although internally Salesforce is treating this like a batch of 200 for Limits sake, there are still going to be 200 Flow interviews that execute for this.

Currently the only way to truly gather all of the records in 1 variable is to place an Invocable Apex class at the start of the Flow to gather these records. Invocable Apex is another place where Salesforce automatically "pauses" the Flow to perform bulkification. Here you can pass these records into an Apex class and return an Sobject Collection of 200 records.

If you do this you need to recognize that the Apex class will actually return 200 variables, since it got 200 inputs. 1 of them will have 200 records, the other 199 will be blank. You must handle these other 199 and exit the Flow or you will get an error similar to:

The number of Interviews does not match...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.