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
Immacolata De BiaseImmacolata De Biase 

How can I creat a list of sObjects to pass to an Action in Lightning Flows?

I'm working on an autolauched flow and I need to pass a list of sobjects to an apex class. I manage to get a collection of records but it isn't the right type, I need it to be a List
ravi soniravi soni
hi Immacolata,
If you want to pass list of sObject from flow to apex action then try below.
1.) Create a Apex Class First
//Here is dummy Ref. class
public class callApexFromFlow {
    @InvocableMethod (label='Get contacts From Flow') /*This is your flow Lable it can be  anything Like you Name too.*/
/*1. In this Method you can use only one parameters
2. If you want to get list of Records then List<list<objectApiName>> listOflstCon
 or only single records then list<Contact> lstCon*/

     public static void flowMethod(List<list<Contact>> listOflstCon){
        system.debug('@Developer listOflstCon : ' + listOflstCon.size());


In above apex we are fetching  list of contacts.
Now go to flow and folow below steps. 
2.) In Flow Create a Get Records Element and fetch records of contact after create a get records element then folow 3 step.
3.) #1.drag and drop a Action Element 
    #2.add Filter on Type 
    #3. Select  Apex Action 
    #4. search your apex class name and select it 
    #5. In Set Input Values you will be seen your apex class parameter Name 
    #6. Check toggle button 
    #7. In apex parameter input select your get element name
    #8. Done And Save

I hope above info will help you.
let me know if it helps you by marking it as best answer.
Thank you

Rakshana Cube84Rakshana Cube84
Hi Immacolata,

You can use that. The Collection variables are supported in the invocable method.
Make sure your class looks like this:

    public static List<String> Method1 (List<List<Account>> ListAcc){


    public static List<String> Method1(List<List<String>> ListAccIds){

You can retrieve the sobject record or the Ids from the flow.

If you use list<list<account>
//get the first List from the List of Lists
List<Account> AccountListReceived= ListAcc.get(0);

Please mark this as the best answer if that solves your problem. Thank you!