Vlocity Facts #20| Calling an Integration Procedure, DataRaptor from Apex

We can call Integration Procedure from Apex
 
Code Snippet:
String procedureName = 'Type_SubType';
Map <String, Object> ipInput = new Map <String, Object> ();
Map <String, Object> ipOutput = new Map <String, Object> ();
Map <String, Object> ipOptions = new Map <String, Object> ();

/* Populating input map for an Integration Procedure. Follow whatever structure your VIP expects */

                String orderId = '80100000000abcd'; 
                 ipInput.put('orderId', orderId);

/* Call the IP via runIntegrationService, and save the output to ipOutput */

   ipOutput = (Map <String, Object>) vlocity_cmt.IntegrationProcedureService.runIntegrationService(procedureName, ipInput, ipOptions);

System.debug('IP Output: ' + ipOutput);

Example:

Public class CallAccountContactDetails {

Public static void IpCallAccountContactDetails(Id accountId){

String procedureName='Get_AccountContactDetails';

Map <String, Object> ipInput = new Map <String, Object> ();

Map <String, Object> ipOutput = new Map <String, Object> ();

Map <String, Object> ipOptions = new Map <String, Object> ();

ipInput.put('accountId', accountId);

ipOutput=(Map<String,Object>)vlocity_cmt.IntegrationProcedureService.runIntegrationService(procedureName,ipInput, ipOptions);

System.debug('IP Output: ' + ipOutput);

}
}

===========================================================================
We can call DataRaptor Extract/Transfrom/Load from Apex
 

Code Snippet:

/* Specify DataRaptor extract or transform to call */

String DRName = 'DataRaptorName'; 

/* Populate the input JSON */

Map<String, Object> myTransformData = new Map<String, Object>{'MyKey'=>'MyValue'}; 

/* Call the DataRaptor */

vlocity_ins.DRProcessResult result = vlocity_ins.DRGlobal.process(myTransformData, DRName); 

/* Deserialize the DataRaptor output for processing in Apex */ 

List<Map<String, Object>> myTransformResult = (List<Map<String, Object>>)result.toJsonList(); 

Example:

Public class CallDRFromApex{

Public static void CallDRExtract(String InputName, String InputValue){

String DRName='DRAccountExtract';
Map <String, Object> DRinput = new Map <String, Object> {InputName => InputValue} ;
vlocity_cmt.DRProcessResult result= vlocity_ins.DRGlobal.process(DRinput, DRName);
List<Map <String, Object>> myTransformResult = (List<Map<String, Object>>) result.toJsonList(); 

System.debug('DR Extract Result: ' +myTransformResult);

}
}

Reference Link: DataRaptor Calls From Apex

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]