Skip to main content
replaced http://salesforce.stackexchange.com/ with https://salesforce.stackexchange.com/
Source Link
  1. You cannot use the return value of the @InvocableMethod in Process builder. The return values of these methods can be used only in flows or when invoked through REST API. Check this answer for more details: accessing the return value of an InvocableMethod in process builderaccessing the return value of an InvocableMethod in process builder

  2. Regarding how to pass two parameters, Override your actual method with another method which takes one parameter of List of primitives then split and call your actual method. Something like this:

    public with sharing class ExampleClass {
    
        public static Integer innerMethod(Date d1,Date d2){
            return d1.monthsBetween(d2);
        }
    
        @InvocableMethod(label='Example' description='Example')
        public static void innerMethodInvocable(List<Date> dates){
            innerMethod(dates[0],dates[1]);
        }    
    }
    
  1. You cannot use the return value of the @InvocableMethod in Process builder. The return values of these methods can be used only in flows or when invoked through REST API. Check this answer for more details: accessing the return value of an InvocableMethod in process builder

  2. Regarding how to pass two parameters, Override your actual method with another method which takes one parameter of List of primitives then split and call your actual method. Something like this:

    public with sharing class ExampleClass {
    
        public static Integer innerMethod(Date d1,Date d2){
            return d1.monthsBetween(d2);
        }
    
        @InvocableMethod(label='Example' description='Example')
        public static void innerMethodInvocable(List<Date> dates){
            innerMethod(dates[0],dates[1]);
        }    
    }
    
  1. You cannot use the return value of the @InvocableMethod in Process builder. The return values of these methods can be used only in flows or when invoked through REST API. Check this answer for more details: accessing the return value of an InvocableMethod in process builder

  2. Regarding how to pass two parameters, Override your actual method with another method which takes one parameter of List of primitives then split and call your actual method. Something like this:

    public with sharing class ExampleClass {
    
        public static Integer innerMethod(Date d1,Date d2){
            return d1.monthsBetween(d2);
        }
    
        @InvocableMethod(label='Example' description='Example')
        public static void innerMethodInvocable(List<Date> dates){
            innerMethod(dates[0],dates[1]);
        }    
    }
    
Source Link
javanoob
  • 9k
  • 15
  • 77
  • 143

  1. You cannot use the return value of the @InvocableMethod in Process builder. The return values of these methods can be used only in flows or when invoked through REST API. Check this answer for more details: accessing the return value of an InvocableMethod in process builder

  2. Regarding how to pass two parameters, Override your actual method with another method which takes one parameter of List of primitives then split and call your actual method. Something like this:

    public with sharing class ExampleClass {
    
        public static Integer innerMethod(Date d1,Date d2){
            return d1.monthsBetween(d2);
        }
    
        @InvocableMethod(label='Example' description='Example')
        public static void innerMethodInvocable(List<Date> dates){
            innerMethod(dates[0],dates[1]);
        }    
    }