top of page
OmniStudioFactBg.png
Writer's pictureGayathiri Mohan

Invoke Integration Procedure from Flow

Updated: Oct 10, 2023

Let us see how to invoke an Integration Procedure from a record-triggered and a screen flow in this article.

Invoke Integration Procedure from a record-triggered flow:


Steps to configure using ‘Apex Action’ :


1) Create an apex class with a method containing the @InvocableMethod annotation.

Please refer to the below code snippet for the same.


global with sharing class InvokeIntegrationProcedure {
 
//invocable method that invokes the ‘Integration Procedure’ with the required input variables and returns the output variables sent from the Integration Procedure.

 @InvocableMethod(label = 'Integration Procedure')
 global static List <IntegrationProcedureOutput> runIntegrationServiceInvocable(List <IntegrationProcedureInput> input) {

  IntegrationProcedureOutput result = new IntegrationProcedureOutput();
  result.output = JSON.serialize(
   vlocity_cmt.IntegrationProcedureService.runIntegrationService(
    input[0].procedureAPIName,
    new Map < String, Object >
    {
     'Id' => input[0].input
    },
    new Map < String, Object > ()));
  return new List < IntegrationProcedureOutput >
   {
    result
   };
 }

 //class containing the input variables (with the ‘@InvocableVariable’ annotation) to be passed to the Integration Procedure from the Flow
 global class IntegrationProcedureInput
 {
  @InvocableVariable(label = 'Procedure Name') global String procedureAPIName;
  @InvocableVariable(label = 'Input') global String input;
 }

 //class containing the output variables (with the ‘@InvocableVariable’ annotation) returned from the Integration Procedure to the Flow
 global class IntegrationProcedureOutput
 {
  @InvocableVariable(label = 'Output') global String output;
 }
}

Here, ‘vlocity_cmt’ denotes the namespace of the installed package. This has to be replaced with the namespace of the Omnistudio package installed in your organization.


2) Now, from your record-triggered flow, add an action of type ‘Apex Action’ and start typing ‘Integration Procedure’.

The apex class created for invoking the Integration Procedure will start showing up.


Select it and enter the details of the Apex Action. Populate the input values as required.

In the below example, there are two input values. Procedure Name - This holds the name of the Integration Procedure in the format Type_SubType’.

Input - This contains the required input to be passed to the Integration Procedure.



3) Use the output from the Integration Procedure and perform the required action based on the need.

In the below example, the output from the Integration Procedure ‘{!InvokeIP.output}’ is used to update a field in the record.


Here, ‘InvokeIP’ is the API Name of the Apex Action and ‘output’ is the output variable declared with the ‘@InvocableVariable’ annotation in the apex class.





NOTE:

Since we cannot perform a DML operation prior to a callout (in the same transaction), in order to invoke an Integration Procedure containing an HTTP action from a record-triggered flow, the flow has to be configured to run on an asynchronous path, as below:



Now you can add the ‘Apex Action’ (containing the logic to invoke the Integration Procedure) inside the ‘Run Asynchronously’ path.




Invoke Integration Procedure from a Screen flow:

To invoke an Integration Procedure from a ‘Screen Flow’, apart from the 'Apex Action' approach mentioned above, we can also use a custom LWC.


Follow the below steps to invoke an Integration Procedure from a 'Screen Flow' using a custom LWC.


Steps to configure using ‘custom LWC’:


1) To expose a LWC in a screen flow, add the below ‘target’ tag in the ‘meta.xml’ file of the LWC.


2) In order to pass some input values from the Screen flow to the LWC, add properties under the ‘targetConfig’ tag in the ‘meta.xml’ file of the LWC.

You can add any number of properties under the ‘targetConfig’ tag, based on the need.


3) Declare a public property using the ‘@api’ decorator to capture the values passed from the parent flow in the ‘.js’ file of the LWC.


4) Add logic in the LWC to invoke an Integration Procedure (IP) by passing the necessary input parameters. (Please refer to the second link on the ‘References’ section on how to invoke an IP from a LWC.)

5) Add a screen element to the flow, and drag and drop the LWC inside.

Enter the API name and the input parameters as needed and save it.




In this way, you can use a custom LWC to invoke an Integration Procedure from a Screen flow.


References:










503 views0 comments

Recent Posts

See All

Yorumlar


bottom of page