Developers can use the Invocable Action mechanism to build a functionality which could be used by admins or non-coding consultants to do declarative programming around process builders and flows salesforce technology . To build focused action we need to use apex class that accepts inputs and returns data via output parameters. Admins can use input fields via flows to supply input into the apex method and use output parameters to return data back to UI via flows (screen flows).
Use the @InvocableMethod annotation to identify methods that can be run as invocable actions and use the @InvocableVariable annotation to identify variables used by invocable methods in custom classes.
Packaging Invocable Actions (managed packages):
You can build packages with invocable methods, once included the invocable method cannot be removed 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.
Considerations for using InvocableMethod:
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.
Considerations for using InvocableMethod:
Only global and public variables can be invocable variables. Other complete list of considerations is available on salesforce developer site.
To demonstrate the usage of Invocable Actions we will supply 3 input (say Name , Age and Place ) via screen flows into Invocable Action and display the output message on screen flows .
The screen flow with Invocable Action:
The input screen element to capture input data which will passed as Input parameters into Invocable method .
The Invocable Apex Action element:
The output display screen element to display output parameters sent back from Invocable method.
Test Input Data into flow Debug screen:
The flow interview output:
Comments
Post a Comment