Invocable Methods with multi parameters

Apex Jan 3, 2020

Invocable methods can have only have one Input parameter, In order to pass multiple params in apex class one should use InvocableVariable annotations

Use Case: Send SMS using Process builder

In Order to send a SMS we need 2 params 1. To Number and other is 2. SMS Body and also consider optional param 3. Appointment Date

If we create an Apex Invocable method it has limitation of only one param which doesn't help in our above use case so to make it work we need to InvocableVariable

Following class is an SmsUtility which sends msg to mobile number (logic for sending msg is not included).

NOTE: Label='Send SMS' you need to search with same in process builder under action type Apex Class

global class SMSUtility {
    @InvocableMethod(label='Send SMS' description='method description')
    // here input param is smsRequest of List type
    global static void smsList(smsRequest[] requests){
        for (smsRequest request : requests) {
           now perform your logic with input params e.g., 	  

           request.toNumber, request.smsBody
    global class smsRequest {
        global String toNumber;
        global String smsBody;
        global String appointmentDate;

Above InvocableVariable will be shown as Input in process builder as follows

Achieve multi params using InvocableVariables in InvocableMethods

Feel free to comment for suggestions/help

Phanindra Mangipudi

Salesforce, Lightning Web Componets, Node.Js, Angular 2+, Bootstrap