Vlocity Facts #24| Calling an Integration Procedure from Salesforce Flows

 We can call Integration Procedure from Salesforce Flows

we can use Integration procedure[IP] for complex requirements like for call outs, record creation or deletion, looping between records and performing Aggregative functions with out using Apex. 

Either we can use Apex class to call IP or In Flexcards, Omniscripts. But we can't call IP when ever any event happens on record to handle this we can use salesforce flows [record trigger flow or screen flow] to call Integration procedure.

Scenario: When amount >= 1000 we need to execute some set of steps like callouts or updating related records by using record trigger flow we can trigger IP.

1. Apex Class: 

global with sharing class IntegrationProcedureInvocable {
@InvocableMethod(label = 'Integration Procedure')
global static List < IntegrationProcedureOutput > runIntegrationServiceInvocable(List < IntegrationProcedureInput > input) {
System.debug(LoggingLevel.Error, JSON.serialize(input));
IntegrationProcedureOutput result = new IntegrationProcedureOutput();
result.output = JSON.serialize(
namespace.IntegrationProcedureService.runIntegrationService(
input[0].procedureAPIName,
new Map < String, Object >
 {
 'Id' => input[0].input
},
new Map < String, Object > ()));
System.debug(LoggingLevel.Error, JSON.serialize(result));
return new List < IntegrationProcedureOutput >
{
 result
};}
global class IntegrationProcedureInput
{
@InvocableVariable(label = 'Procedure Name') global String procedureAPIName;
@InvocableVariable(label = 'Input') global String input;
}
global class IntegrationProcedureOutput
{
@InvocableVariable(label = 'Output') global String output;
}}

When calling 
IntegrationProcedureService.runIntegrationService, be sure to replace the namespace with omnistudiovlocity_cmtvlocity_ins, or vlocity_ps.

Input Settings

Procedure Name: Specify the Integration Procedure to be run using this format: Type_SubType (note the underscore).

Input: For each input variable required by the Integration Procedure, choose Variable and specify the name of the input variable using the following format: {!variableName}

Output Settings: For each variable that is returned by the Integration Procedure, choose Variable and specify the name of the output variable using the following format: {!variableName}

2. Salesforce Record Trigger Flow

 Create record trigger flow on opportunity with condition when Amount >= 1000
Image

Now drag and drop one apex action in that select the apex class what you have created by using above code and configure like this.
Image

After that activate the flow.


Reference Link: Integration Procedure Call from Salesforce Flow

Comments

Popular posts from this blog

Vlocity Facts #01 | OmniStudio DataRaptors

Vlocity Facts #34 || Getting the details from the URL in a FlexCard and an Omniscript

Vlocity Facts #44 || Communication between Omniscript and Flexcard [Pub/Sub]