I have an invokable apex method that I need to call from a Flow. Invokable methods are strict in the data type of their parameters -- I can't simply pass a string, instead, I have to pass a list<String>. OK, no biggie. Here's the method:

    public class ARpromptFirstName
    @InvocableMethod(label='Send AutoResponse FirstName' description='Needs ConversationIdList')
    public static void sendAutoResponseFirstName(List<String> ConversationIds)
        for (String Id : ConversationIds)
            String msgBody = 'Please enter your first name.';
            SaveSendSMS.sendSMSfromLightning(Id, msgBody);

The method works fine when I call it from Anonymous Apex. My problem is calling it from the Flow. The method shows up in the Flow palette, and I can drag it into the Flow, but it won't allow me to assign a collection variable to the ConversationIds parameter. It gives me the choice of all my other (singleton) variables, but not the collection variable named ConversationIds to which I have added the individual {!ConversationId} I need to pass. I think it's odd that it allows primitive data types to be passed to a parameter that is a list<string>. (And, no, the method won't work if I just pass a single string value instead of the list.) That suggests a breakdown in communications between the APEX method and the Flow Designer.

enter image description here

YES, the flow variable is set to Output (I've tried Input/Output as well). enter image description here

Checking the documentation, it says:

Pass information from the flow to the invoked Apex method. The method determines the available input parameters and their data types.

As you can see in the method code above, my method clearly indicates list<string>. The flows editor doesn't allow you to be that clear when you create variables. I've created a "Collection Variable" of type "Text". I think that's about as close as one can get to a list of strings.

A day later... I suspected that the flow's Collection variable of type Text isn't exactly a list<String>, so I've tried changing the method to accept a list<Conversation__c> parameter instead, creating an SObject Collection variable in the Flow. But guess what... that doesn't work either. Only the singular variables/sObject variables appear in the pulldown menu of items that can be assigned as the parameter when calling the APEX method. Frustrating... Flow can't send a list, APEX can only accept a list.

I've combed the docs for Invokable Apex and for the Flow Designer -- can't find anything I've overlooked. I'm hoping one of you can spot something... Thanks.

2 Answers 2


I ran into this same exact scenario. Another solution that worked for me was changing the @InvocableMethod parameter to: List<List<String>> and then reference the variable accordingly in the rest of the code. Once I did that and went back to my visual workflow APEX call element, I could choose or create a collection in the input parameters.

  • Your solution works.
    – Ankuli
    Commented Aug 8, 2018 at 9:47
  • OMG Salesforce ... okay. A million thanks for coming up with this hack ... managed to do a List<List<Custom_Object__c>> this way, too.
    – k..
    Commented Apr 10, 2019 at 11:36

Answering my own question here. Turns out, you can pass a singleton parameter into a list<sObject> Invokable Method. It appears to be like a trigger, where you write it for bulk, but it executes OK on an individual. I should have thought to test for that sooner.

  • yes, the analogy is like in PB to @invocable Apex. The invocable gets a collection but the PB action group defines the singleton; PB actions are "bulkified" before executing. There's a somewhat related post on this here
    – cropredy
    Commented Mar 16, 2018 at 17:23

You must log in to answer this question.

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