#1MinuteTip Here is an excellent video (1:00:39 hrs) on Salesforce Developers Channel on YouTube showing you how call Apex from Flow and pass the values back and forth.
Using Apex with Flows will give you the best of both worlds – that is allow you to leverage on the declarative as well as programmatic capabilities of Salesforce.
To call Apex from Flow, you need to define the method in your Apex Class as an Invocable Method. And here are some of the rules that you need to follow when using Invocable Method:
- The Apex class must be defined as public or global.
- There can be only one invocable method in the Apex class.
- The invocable method must be static and public or global, and its class must be an outer class.
- There can be at most one input parameter to Apex method and its data type must be of list type.
- The data type returned by the method must also be of the list type
References & Useful URLs
- Salesforce Apex Developer Guide – InvocableMethod Annotation