We have a flow that stores the collection of Ids with Email address and we want to pass those Ids to send an email from Apex. I'm Trying to call the apex but it gives me error list has no rows. Couldn't find the any answer. I'm not sure how to pass the Multiple Email parameters from Invocable.

Updated Code & Screen shot. I need to be able to pass the correct Email address collection to the Apex invocable parameter string. Could you please tell me where I'm doing wrong? Do i still require loop variable?

enter image description here enter image description here enter image description here

public class SendEmailAction {
    @InvocableMethod(label='Send SE Email Notification') 
public static void SendSENotification(List<string> Emailaddresses){
        List<OrgWideEmailAddress> lstEmailAddress=[select Id from OrgWideEmailAddress WHERE Address='[email protected]'];
        List<EmailTemplate> SEEmailTemplate= [Select Id, Name, DeveloperName from EmailTemplate where DeveloperName= 'Safety_Event_New_Event_Reported'];
         Messaging.SingleEmailMessage[] mails = new Messaging.SingleEmailMessage[0];
        for(string Ids : Emailaddresses) {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

1 Answer 1


Inside your Apex Action, under the Set Input Values section you need to ensure that you have checked/moved the slider to include your input.

Invocable methods can be hard to wrap your mind around sometimes, because when you see that it takes a List<DATATYPE> as input, you actually send it a single DATATYPE from the Flow. If you want to be able to send it a list (a collection) from the Flow, then you need to change the method to take a List<List<DATATYPE>>.

Since you have a collection variable that holds your emails, you might want to change your Apex method to take a List<List<String>> Emailaddresses. That way you can call your Apex Action at the end of your Loop (After Last Item) instead of calling it once per email address in the midst of your Loop.


[It was late for me and I forgot to include this for more completeness.]

You could instead add an Invocable Variable[*] inside a separate inner class, which essentially is used as a wrapper for input (and can be used for any output), and can make it more generic. However, Invocable Variables like this can add more layers of complexity (and confusion for those not fully comfortable with Invocable Methods), so it is not always a good thing if you do not need it.

[*] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableVariable.htm


You must log in to answer this question.

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