Vlocity/Omnistudio

Call Integration Procedure From Apex Code

Using Apex code from a Remote action or a typical Apex Method, developers can call an Integration Procedure (IP) and store the response of it.

Let's see an example on how to do it:

Call Integration Procedure From Apex Class

Integration Procedure

First we need to have an Integration Procedure created and activated, in this case we will use an IP which receive a string as an input and updates different Accounts using that input:

How to call an Integration Procedure from Apex Code

Apex Code

Important: before to call the Integration Procedure check the Vlocity namespace on your organization. You will need to specify that namespace when you call the IP. In my case I have vlocity_ins, you can check it on Setup > Installed Packages > Vlocity Insurance

Salesforce Vlocity namespace of each organization

Once the Integration Procedure is created and activated you can call it from Apex using this code below:

String integrationProcedure = 'UpdateAccounts_Example'; // TYPE_SUBTYPE
Map<String, Object> ipInput = new Map<String, Object>();
Map<String, Object> ipOptions = new Map<String, Object>();
Map<String, Object> ipResponse = new Map<String, Object>();

// POPULATE THE INPUT MAP
ipInput.put('accIndustry', 'Finance');
// POPULATE THE OPTIONS MAP (OPTIONAL)
ipOptions.put('chainable', true);

// CALL AND STORE THE RESPONSE OF THE IP
ipResponse = (Map <String, Object>)vlocity_ins.IntegrationProcedureService.runIntegrationService(integrationProcedure, ipInput, ipOptions);

Make sure to use your own Vlocity Namespace on the when you call it on the last line of code.