DRGlobal Class and Methods

Use the ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput) Connect API to call Data Mappers from Apex through the DRGlobal Apex class. Starting with Summer ’25, replace the existing methods in the DRGlobal Apex classes with the Connect API.

Process a JSON String Object List Using a Specified Data Mapper

The objectList must be a JSON String.

Connect API Existing Method (Replace with Connect API)
List<String> jsonInputData = new List<String>();
jsonInputData.add(objectList);

ConnectApi.DataMapperExecuteInputRepresentation apexInput = new ConnectApi.DataMapperExecuteInputRepresentation();
apexInput.dataMapperInput = jsonInputData;
apexInput.inputType = 'JSON';

ConnectApi.DataMapperExecuteOptionsRepresentation options = new ConnectApi.DataMapperExecuteOptionsRepresentation();

options.ignoreCache = false;
options.shouldSendLegacyResponse = true;
apexInput.options = options;

ConnectApi.DataMapperExecuteOutputRepresentation output = ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput);

List<String> innerResponse = output.response;

String currentResponse = innerResponse[0];

System.debug(currentResponse);

Map<String, Object> outerMap = (Map<String, Object>) JSON.deserializeUntyped(currentResponse);

List<String> keys = new List<String>(outerMap.keySet());

System.debug(outerMap.get('drSObjectResults'));

static namespace.DRProcessResult processObjectsJSON(String objectList, String bundleName)

namespace.DRProcessResult res = namespace.DrGlobal.processObjectsJSON(objectList, bundleName);

Process a List of sObjects Using a Specified Data Mapper

Connect API Existing Method (Replace with Connect API)

String jsonstring = JSON.serialize(objectList);
List<String> jsonInputData = new List<String>();
jsonInputData.add(jsonString);

ConnectApi.DataMapperExecuteInputRepresentation apexInput = new ConnectApi.DataMapperExecuteInputRepresentation();
apexInput.dataMapperInput = jsonInputData;apexInput.inputType = 'JSON';

ConnectApi.DataMapperExecuteOptionsRepresentation options = new ConnectApi.DataMapperExecuteOptionsRepresentation();
options.ignoreCache = false;
options.shouldSendLegacyResponse = true;

apexInput.options = options;

ConnectApi.DataMapperExecuteOutputRepresentation output = ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput);

List<String> innerResponse = output.response;

for (String currentResponse : innerResponse) {
   System.debug(currentResponse);
   Map<String, Object> outerMap = (Map<String, Object>)JSON.deserializeUntyped(currentResponse);
   List<String> keys = new List<String>(outerMap.keySet());
   System.debug(outerMap.get('drSObjectResults'));
}

                static namespace.DRProcessResult processObjects(List<SObject> objectList)

This signature, which doesn't require a DRName, is only for a Data Mapper Load.


String jsonString = '';
if (additionalInfo != null) {
  jsonString = JSON.serialize(additionalInfo);
} else {
  jsonString = JSON.serialize(objectList);
}

List<String> jsonInputData = new List<String>();

jsonInputData.add(jsonString);

ConnectApi.DataMapperExecuteInputRepresentation apexInput = new ConnectApi.DataMapperExecuteInputRepresentation();

apexInput.dataMapperInput = jsonInputData;

apexInput.inputType = 'JSON';

ConnectApi.DataMapperExecuteOptionsRepresentation options = new ConnectApi.DataMapperExecuteOptionsRepresentation();

options.ignoreCache = false;
apexInput.options = options;
options.shouldSendLegacyResponse = true;

ConnectApi.DataMapperExecuteOutputRepresentation output = ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput);

List<String> innerResponse = output.response;

for (String currentResponse : innerResponse) {
  Map<String, Object> outerMap = (Map<String, Object>)JSON.deserializeUntyped(currentResponse);
  List<String> keys = new List<String>(outerMap.keySet());
  System.debug(outerMap.get('drSObjectResults'));
}

static namespace.DRProcessResult processObjects(List<SObject> objectList,String bundleName,Map<String, Object> additionalInfo, Map<String, Object> filesMap
)

The additionalInfo is a Map that applies to every SObject, such as extra data for processing.


String jsonString = '';

if(additionalInfo !=null){
jsonString= JSON.serialize(additionalInfo);

}else{

jsonString= JSON.serialize(objectList);
}

List<String> jsonInputData = new List<String>();
jsonInputData.add(jsonString);

ConnectApi.DataMapperExecuteInputRepresentation apexInput = new ConnectApi.DataMapperExecuteInputRepresentation();
apexInput.dataMapperInput = jsonInputData;
apexInput.inputType = 'JSON';

ConnectApi.DataMapperExecuteOptionsRepresentation options = new ConnectApi.DataMapperExecuteOptionsRepresentation();
options.shouldSendLegacyResponse = true;
apexInput.options = options;

ConnectApi.DataMapperExecuteOutputRepresentation output  = ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput);

List<String> innerResponse = output.response;

for (String currentResponse : innerResponse){
Map<String, Object> outerMap = (Map<String, Object>) JSON.deserializeUntyped(currentResponse);
List<String> keys = new List<String>(outerMap.keySet());
System.debug(outerMap.get('drSObjectResults'));
}
static namespace.DRProcessResult processObjects(List<SObject> objectList, String bundleName, Map<String, Object> additionalInfo)

The additionalInfo is a Map that applies to every SObject, such as extra data for processing.

Process a list or map of objects, bypassing sharing rules, with a specified Data Mapper and locale

These methods ignore Sharing Rules, which ensures that the Data Mapper being invoked is private. See Sharing Rules in the Salesforce Help.

Connect API Existing Method (Replace with Connect API)

String jsonString = JSON.serialize(objectList);
List<String> jsonInputData = new List<String>();
jsonInputData.add(jsonString);

ConnectApi.DataMapperExecuteInputRepresentation apexInput = new ConnectApi.DataMapperExecuteInputRepresentation();
apexInput.dataMapperInput = jsonInputData;apexInput.inputType = 'JSON';
ConnectApi.DataMapperExecuteOptionsRepresentation options = new ConnectApi.DataMapperExecuteOptionsRepresentation();
options.locale = locale;
options.shouldSendLegacyResponse = true;
apexInput.options = options;

ConnectApi.DataMapperExecuteOutputRepresentation output  = ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput);
List<String> innerResponse = output.response;

for (String currentResponse : innerResponse){
Map<String, Object> outerMap = (Map<String, Object>) JSON.deserializeUntyped(currentResponse);
List<String> keys = new List<String>(outerMap.keySet());
System.debug(outerMap.get('drSObjectResults'));

}
Note
Note Users must have appropriate permissions to execute the Data Mapper.

static namespace.DRProcessResult processFromApex(
List<Map<String, Object>> objectList,
String bundleName,
String locale
)

String jsonString = JSON.serialize(objectList);

List<String> jsonInputData = new List<String>();
jsonInputData.add(jsonString);

ConnectApi.DataMapperExecuteInputRepresentation apexInput = new ConnectApi.DataMapperExecuteInputRepresentation();
apexInput.dataMapperInput = jsonInputData;
apexInput.inputType = 'JSON';
ConnectApi.DataMapperExecuteOptionsRepresentation options = new ConnectApi.DataMapperExecuteOptionsRepresentation();
options.locale = locale;
options.shouldSendLegacyResponse = true;
apexInput.options = options;
ConnectApi.DataMapperExecuteOutputRepresentation output = ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput);
List<String> innerResponse = output.response;
for (String currentResponse : innerResponse) {
Map<String, Object> outerMap = (Map<String, Object>)JSON.deserializeUntyped(currentResponse);
List<String> keys = new List<String>(outerMap.keySet());
System.debug(outerMap.get('drSObjectResults'));
}
Note
Note Users must have appropriate permissions to execute the Data Mapper.

static namespace.DRProcessResult processFromApex(
Map<String, Object> objectList,
String bundleName,
String locale
)

Process a list or map of objects with a specified Data Mapper and locale, considering sharing rules

Connect API Existing Method (Replace with Connect API)

String jsonString = JSON.serialize(objectList);
List<String> jsonInputData = new List<String>();
jsonInputData.add(jsonString);

ConnectApi.DataMapperExecuteInputRepresentation apexInput = new ConnectApi.DataMapperExecuteInputRepresentation();
apexInput.dataMapperInput = jsonInputData;
apexInput.inputType = 'JSON';
ConnectApi.DataMapperExecuteOptionsRepresentation options = new ConnectApi.DataMapperExecuteOptionsRepresentation();
options.locale = locale;
options.shouldSendLegacyResponse = true;
apexInput.options = options;

ConnectApi.DataMapperExecuteOutputRepresentation output = ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput);
List<String> innerResponse = output.response;

for (String currentResponse : innerResponse) {
Map<String, Object> outerMap = (Map<String, Object>)JSON.deserializeUntyped(currentResponse);
List<String> keys = new List<String>(outerMap.keySet());
System.debug(outerMap.get('drSObjectResults'));
}

static namespace.DRProcessResult process(
List<Map<String, Object>> objectList,
String bundleName,
String locale
)

String jsonString = JSON.serialize(objectList);

List<String> jsonInputData = new List<String>();
jsonInputData.add(jsonString);

ConnectApi.DataMapperExecuteInputRepresentation apexInput = new ConnectApi.DataMapperExecuteInputRepresentation();
apexInput.dataMapperInput = jsonInputData;
apexInput.inputType = 'JSON';

ConnectApi.DataMapperExecuteOptionsRepresentation options = new ConnectApi.DataMapperExecuteOptionsRepresentation();
options.locale = locale;
options.shouldSendLegacyResponse = true;
apexInput.options = options;

ConnectApi.DataMapperExecuteOutputRepresentation output = ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput);

List<String> innerResponse = output.response;

for (String currentResponse : innerResponse) {
Map<String, Object> outerMap = (Map<String, Object>)JSON.deserializeUntyped(currentResponse);
List<String> keys = new List<String>(outerMap.keySet());
System.debug(outerMap.get('drSObjectResults'));
}

static namespace.DRProcessResult process(
Map<String, Object> objectList,
String bundleName,
String locale
)

Upload data with the bulkupload parameter

This method can only call a Data Mapper Load. No other Apex method can pass the bulkUpload parameter to a Data Mapper. See Omnistudio Data Mapper Calls From Apex.

Connect API Existing Method (Replace with Connect API)

Synchronous Processing:


List < Account > accounts = new List <Account>();
accounts.add(new Account(Name = 'TesterAccountWithBundleName', vlocity_ins__Active__c='true'));
accounts.add(new Account(Name = 'TesterAccount2WithBundleName', vlocity_ins__Active__c='true'));
accounts.add(new Account(Name = 'TesterAccount3WithBundleName', vlocity_ins__Active__c='true'));
accounts.add(new Account(Name = 'TesterAccount2WithBundleName', vlocity_ins__Active__c='true'));
....
accounts.add(new Account(Name = 'TesterAccount200WithBundleName', vlocity_ins__Active__c='true'));

List<String> jsonInputData = new List<String>();
jsonInputData.add(JSON.serialize(accounts)); 

ConnectApi.DataMapperExecuteInputRepresentation apexInput = new ConnectApi.DataMapperExecuteInputRepresentation();
apexInput.dataMapperInput = jsonInputData;
apexInput.inputType = 'JSON';
ConnectApi.DataMapperExecuteOptionsRepresentation options = new ConnectApi.DataMapperExecuteOptionsRepresentation();
options.ignoreCache = false;
apexInput.options = options;
options.shouldSendLegacyResponse = true;
ConnectApi.DataMapperExecuteOutputRepresentation output = ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput);

List<String> innerResponse = output.response;

Map<String, Object> outerMap = (Map<String, Object>) JSON.deserializeUntyped(innerResponse[0]);
List<String> keys = new List<String>(outerMap.keySet());
System.debug(outerMap.get('drSObjectResults'));

Here's the output:

{Account_1=({Id=001xx000003GpXjAAK, Name=TesterAccountWithBundleName, UpsertSObjectType=Account, UpsertSuccess=true}, 
{Id=001xx000003GpXkAAK, Name=TesterAccount2WithBundleName, UpsertSObjectType=Account, UpsertSuccess=true}, 
{Id=001xx000003GpXlAAK, Name=TesterAccount3WithBundleName, UpsertSObjectType=Account, UpsertSuccess=true}, 
{Id=001xx000003GpXmAAK, Name=TesterAccount4WithBundleName, UpsertSObjectType=Account, UpsertSuccess=true} ....... )}

There is a mismatch in the output during the synchronous processing. Perform these steps to match the exact output.

 
  Map<String, Object> mapReturn = new Map<String,Object>();
  
  mapReturn.put('createdObjectsByType', createdObjectsByType);
  mapReturn.put('createdObjectsByOrder', createdObjectsByOrder);
  if (overrideErrors != null) {
  mapReturn.put('errors', overrideErrors);
  } else {
  mapReturn.put('errors', errors);
  }
  mapReturn.put('errorsByField', errorsByField);
  mapReturn.put('interfaceInfo', interfaceInfo);
  //if (String.isBlank(responseType) || responseType == 'SObject')
  {
  mapReturn.put('errorsAsJson', errorsAsJson());
  }
  
  mapReturn.put('hasErrors', hasAnyError);
  if (responseCache != null && String.isNotBlank(responseTypeCache))
  {
  mapReturn.put('returnResultsData', responseCache);
  mapReturn.put('responseType', responseTypeCache);
  }
  else if (responseType != null && responseType.equalsIgnoreCase('xml'))
  {
  JsonToXml json2xml = new JsonToXml((Map<String, Object>)toJson(), 
  new Map<String, Object> { 
  'fieldWriteOrder' => xmlOuputSequence, 
  'removeDeclaration' => xmlRemoveDeclaration 
  });
  mapReturn.put('responseType', 'XML');
  mapReturn.put('returnResultsData', json2xml.getXml());
  }
  else if (responseType != null && responseType == 'Custom')
  {
  mapReturn.put('responseType', 'Custom');
  mapReturn.put('returnResultsData', processCustomOutputType());
  }     
  else
  {
  mapReturn.put('responseType', 'JSON');
  mapReturn.put('returnResultsData', toJson());
  }
  if (fileAttachmentSyncData.size() > 0)
  {
  mapReturn.put('fileAttachmentSyncData', fileAttachmentSyncData);
  }
  if (Logger.DebugRecordingMode)
  {
  mapReturn.put('debugLog', Logger.recordedDebugStatements);
  mapReturn.put('CpuTime', Limits.getCPUTime());
  mapReturn.put('ActualTime', DateTime.now().getTime() - startForServerTiming);
  }
  return mapReturn;
global static Map<String, Object> processPost(Map<String, Object> bodyData)

Existing approach for synchronous processing


String bundleName = 'DRWithLoad'; // Data Mapper name
String bulkUpload = 'false';

Map<String,Object> bodyData = new Map<String,Object>();
bodyData.put('bundleName',bundleName);
bodyData.put('bulkUpload', bulkUpload);
bodyData.put('objectList',objectList);

Map<String,Object> result= vlocity_ins.DRGlobal.processPost(bodyData);

System.debug(result);

Map<String,Object> result= vlocity_ins.DRGlobal.processPost(bodyData);

System.debug(JSON.serialize(result));
Connect API to asynchronously upload data using the 'bulkupload' parameter is not available.

String bundleName = 'DRWithLoad'; // Data Mapper name

String bulkUpload = 'true';

Map<String,Object> bodyData = new Map<String,Object>();
bodyData.put('bundleName',bundleName);
bodyData.put('bulkUpload', bulkUpload);
bodyData.put('objectList',objectList);

Map<String,Object> result= vlocity_ins.DRGlobal.processPost(bodyData);

System.debug(result);

Process an XML String Using a Specified Data Mapper

Connect API Existing Method
List<String> jsonInputData = new List<String>();
jsonInputData.add(objectList);

ConnectApi.DataMapperExecuteInputRepresentation apexInput = new ConnectApi.DataMapperExecuteInputRepresentation();

apexInput.dataMapperInput = jsonInputData;
apexInput.inputType = 'XML';

ConnectApi.DataMapperExecuteOptionsRepresentation options = new ConnectApi.DataMapperExecuteOptionsRepresentation();
options.ignoreCache = false;
options.shouldSendLegacyResponse = true;

apexInput.options = options;

ConnectApi.DataMapperExecuteOutputRepresentation output = ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput);

List<String> innerResponse = output.response;
Map<String, Object> outerMap = (Map<String, Object>) JSON.deserializeUntyped(innerResponse[0]);
List<String> keys = new List<String>(outerMap.keySet());
System.debug(outerMap.get('drSObjectResults'));
static namespace.DRProcessResult processString(String input, String bundleName)