Invocable Apex

What is invocable apex? Where do we use invocable methods and variables?

We use @InvocableMethod annotation, whenever we want to invoke an apex method from Process Builder, Flow and Einstein Chatbot. To invoke apex method from mentioned out of the box tools, @InvocableMethod annotation must be used. To use the variables for input/output @InvocableVariable is used.

Places where we can invoke Apex

Process Builder

We need to select the Action as --> Apex in the Process Builder.

Lightning Flows

Keeping the invocable apex class in mind, search the class name in the flow actions.

Einstein Bot

Select Apex in the new Action of an Einstein bot.

Syntax of Invocable Method and Variable

public class SampleClassName

{

@InvocableMethod

public static void methodName(DataType parameters)

{

[Body of the Method]

}

@InvocableVariable

global DataType variableName;

}

Happy Coding !!!!!