How to Call Apex Class From Salesforce Flow

Sometimes, automating the process using Salesforce flow can be limited by the capabilities for handling complex logic. So, for that, we can use an apex class to automate the process and then call an apex class from a flow.

In this Salesforce tutorial, we will learn how to call an Apex class from Salesforce flow. In this, I will explain what an invocable method is; then, we will create an Apex class and call that Apex class in the flow.

What is the Invocable Method in Salesforce?

To call Apex code from a flow, we need to create an Invocable method within the Apex class. This method is annotated with @InvocableMethod, which makes it accessible to the flow.

The label attribute in the annotation specifies the display name of the Apex Action. Each class can contain only one Invocable Method and accept a single parameter.

There are some considerations to keep in mind when declaring the invocable method in the Apex class.

  • Class Visibility: The Apex class must be defined as public or global. So that it can be accessible from the flows.
  • Method Visibility: The Invocable method must be static and public or global.
  • Class Type: The class must be an outer class.
  • Invocable