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
Saravana RavikumarSaravana Ravikumar 

Can a method using @InvocableMethod have multiple input parameters ?

Arun Kumar 1141Arun Kumar 1141
Hi Saravana,

Yes, a method annotated with '@InvocableMethod' can have numerous input parameters required. The annotation '@InvocableMethod' is used for defining an approach that can be identified by a Flow or Process Builder, and the approach can accept numerous input parameters of various forms.

For example:
You can write an apex code to create Contact having 2 parameters, FirstName and LastName using @InvocableMethod.

If you find this answer helpful, please mark it as best.
Thank you.
Saravana RavikumarSaravana Ravikumar

In the below articles, it is mentioned we can have at most one input parameter. Which I interpret as maximum one input parameter only . Am I correct ?


https://www.biswajeetsamal.com/blog/invocable-method-in-salesforce/
https://techdicer.com/invocable-method-in-apex-salesforce/

Andrew Gillan 30Andrew Gillan 30
Reference:
InvocableMethod Annotation | Apex Developer Guide | Salesforce Developers (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableMethod.htm)

Inputs and Outputs
There can be at most one input parameter and its data type must be one of the following:
  • A list of a primitive data type or a list of lists of a primitive data type – the generic Object type isn’t supported.
  • A list of an sObject type or a list of lists of an sObject type.
  • A list of the generic sObject type (List<sObject>) or a list of lists of the generic sObject type (List<List<sObject>>).
  • A list of a user-defined type, containing variables of the supported types or user-defined Apex types, with the InvocableVariable annotation. Create a custom global or public Apex class to implement your data type, and make sure that your class contains at least one member variable with the invocable variable annotation.
Regards
Andrew