Newer Version Available
InvocableMethod Annotation
Invocable methods are called with REST API and used to invoke a single Apex method. Invocable methods have dynamic input and output values and support describe calls.
The following code sample shows an invocable method with primitive data types.
This code sample shows an invocable method with a specific sObject data type.
This code sample shows an invocable method with the generic sObject data type.
InvocableMethod Modifiers
The invocable method annotation supports the modifiers shown in this example.
@InvocableMethod(label='yourLabel' description='yourDescription')
All modifiers are optional.
- label
- The label for the method, which appears as the action name in Flow Builder. The default is the method name, though we recommend that you provide a label.
- description
- The description for the method, which appears as the action description in Flow Builder. The default is Null.
- category
- The category for the method, which appears as the action category in Flow Builder. If no category is provided (by default), actions appear under Uncategorized.
- configurationEditor
- The custom property editor that is registered with the method and appears in Flow Builder when an admin configures the action. If you don’t specify this modifier, Flow Builder uses the standard property editor,
InvocableMethod Considerations
- Implementation Notes
-
- The invocable method must be static and public or global, and its class must be an outer class.
- Only one method in a class can have the InvocableMethod annotation.
- Other annotations can’t be used with the InvocableMethod annotation.
- 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 is not 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 above 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.
- A list of a primitive data type or a list of lists of a primitive data type – the generic Object type is not 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 above 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.
- Managed Packages
-
- You can use invocable methods in packages, but once you add an invocable method you can’t remove it from later versions of the package.
- Public invocable methods can be referred to by flows and processes within the managed package.
- Global invocable methods can be referred to anywhere in the subscriber org. Only global invocable methods appear in Flow Builder and Process Builder in the subscriber org.
For more information about invocable actions, see Actions Developer’s Guide.