Loading
Prepare for Email to Become the Default Login ExperienceRead More
Automate Your Business Processes with Salesforce Flow
Call Apex Code from a Process

Call Apex Code from a Process

Add customized functionality to your process by calling Apex from the process.

Required Editions

Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience
Available in: Enterprise, Performance, Unlimited, and Developer Editions
User Permissions Needed
To create, edit, or view processes:

Manage Flow

AND

View All Data

Important
Important Support and updates for Process Builder have ended as of December 31, 2025. This means that support won't be provided for any process and bugs in the Process Builder product won't be fixed. See Workflow Rules & Process Builder End of Support.

After December 31, 2025, existing processes continue to run, and you can activate, deactivate, and edit them; however, we recommend using Flow Builder. To migrate existing processes, plan your switch to Flow Builder and use the Migrate to Flow tool. For new automations, create flows in Flow Builder.

After you’ve created an action and selected “Apex” for the type, fill in the relevant fields to add the action to your process.

Important
Important To use this action in a process, ask your developer to annotate the appropriate method with @InvocableMethod. For details, see “InvocableMethod Annotation” in the Apex Developer Guide.

The Apex class and the process are executed by the user whose action triggered the process.

  1. Enter a name for this action. This text appears on the canvas and helps you differentiate this action from others in your process. The name truncates to fit on the canvas.
  2. Choose an Apex class by entering the name of the class to filter results or select a class from the dropdown list.
  3. If the class includes an invocable variable, you can manually enter values or reference field values from a related record.

    The value must match the variable’s data type. You can set values for sObject and primitive type list variables only.

    • To set values for sObject variables and sObject list values, reference an object’s related records, for example, all child contact records associated with the Account object that started the process.
    • To set a value for a primitive list variable (String, Integer, Time, and so on), select the String value type and enter a value in the text input field. You can’t pass multiple values to lists.
  4. Click Save.
    Note
    Note If you define an Apex action in your process and then modify the Apex class by adding a standard field reference (for example, User.Phone), the Apex action is no longer visible in the process and must be added again.
 
Loading
Salesforce Help | Article