[SalesForce] Passing a list of records to an invocable method

The documentation on invocableMethod clearly states that you can pass in a list of a sObject type.

There can be at most one input parameter and its data type must be one of the following:
A list of a primitive data type or a list of lists of a primitive data type – the generic Object type is not supported.
A list of an sObject type or a list of lists of an sObject type – the generic sObject type is not supported.

However, in my flow, i only have the option to pass in a sObject variable – there is no option to pass in a sObject collection (I have a sObject collection set to public input / output in the flow).

optionsInFlowApexElement

So how can you pass a list of a sObject type from flow to invocable method? Seems like you can only pass a single sObject.

Best Answer

Found answer on developer boards from Chad Barbour.

If the expectation is to receive a collection you can use in the flow, you'll need to have your method return a collection of collections. In this case, if you're wanting a list of strings (List), you'll want to have it return a list containing lists of strings (List>).

Apparently a sObject variable is a list, and a sObject collection is a list of lists. So you need to be able to work with lists of lists and then you will have the option to pass / receive sObject collections. Go figure...

Related Topic