Calling an Integration Procedure from a Salesforce Flow

Using Salesforce Flow to call an Integration Procedure enables efficient automation and streamlined data management, particularly in workflows that involve external data or complex multi-step processes. Integration Procedures in OmniStudio are server-side processes that retrieve, save, and transform data. Pairing them with Salesforce Flow empowers low-code automation for intricate data handling tasks.

Step-by-Step Guide to Calling an Integration Procedure from Salesforce Flow

Step 1: Create the Integration Procedure

  • Navigate to OmniStudio: Open the App Launcher, search for OmniStudio, and go to OmniStudio Integration Procedures.
  • Create a New Integration Procedure: Click New, provide a Name and API Name, and set the Type (e.g., Integration or Data Service).
  • Configure Steps: In the Integration Procedure Canvas, configure steps like DataRaptor Extract (for data retrieval), HTTP Action (for external API calls), or Remote Action (for Apex calls).
  • Define the Response: Ensure a Response Action step is configured to define the output returned to the Flow.
  • Test and Activate: Run the Integration Procedure in Preview mode to check functionality, and Activate the procedure once verified.

Step 2: Create the Salesforce Flow

  • Open Flow Builder: Go to Setup > Flows and create a new Flow. Select the Flow type (e.g., Screen Flow or Auto-launched Flow) based on your requirement.
  • Define Flow Elements: Add elements like Screen, Decision, or Assignment to build the Flow structure and guide its behavior.

Step 3: Call the Integration Procedure with Apex

Since Salesforce Flow cannot call Integration Procedures directly, you’ll need to create an Apex class to bridge the Flow and the Integration Procedure.

Creating an Apex Class to Call the Integration Procedure

1. Create a New Apex Class in Developer Console.


public class CallIntegrationProcedure {
    @InvocableMethod(label='Call Integration Procedure' description='Invokes an OmniStudio Integration Procedure')
    public static void invokeProcedure(List<String> inputs) {
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint(URL.getOrgDomainUrl().toExternalForm() + '/services/apexrest/v1/your_integration_procedure_endpoint');
        request.setMethod('POST');
        request.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
        request.setBody('{"inputField": "' + inputs[0] + '"}');

        HttpResponse response = http.send(request);
        // Handle response as needed
    }
}

Adding the Apex Action to Flow

  • Add Apex Action: In Flow Builder, select Action from the Flow Elements menu and choose the Apex action (e.g., CallIntegrationProcedure).
  • Map Inputs: Map necessary inputs, such as IDs or other parameter values required by your Integration Procedure.
  • Configure Output Variables: Set up Flow variables to capture data returned by the Apex action if the Integration Procedure sends data back.

Step 4: Test and Activate the Flow

  • Debug the Flow: Use Flow Builder’s Debug tool to test data passing between the Flow and the Integration Procedure.
  • Activate the Flow: Once tested, click Activate to make the Flow available for use in Lightning pages, record-triggered actions, or scheduled jobs.

Summary and Best Practices

Calling an Integration Procedure from a Salesforce Flow brings OmniStudio’s power into low-code automation. Best practices include limiting data passing to necessary fields, implementing error handling in both Apex and Flow, and thoroughly documenting inputs and outputs for easy maintenance. This setup is ideal for handling data-heavy tasks and API calls, providing end-to-end automation and precise data processing in Salesforce environments.