---
schema_version: "1"
id: 4a2c28df0636d418bacaf1aeeb052f25b8698fa9d05cf625c4172e97e964f6a5
title: Omnistudio Data Mapper Calls From Apex
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_dataraptor_calls_from_apex_47779.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_dataraptor_calls_from_apex_47779.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: aa12b212fa7f1c63fe926123e77bf4707acf8b2f14a0ca7a6ad8aae92cbcb6b7
description: Starting with Summer’ 25, to call a Data Mapper from Apex, call the ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput) Connect API specifying the name of the Data Mapper and the input data that it requires. This API replaces the vlocity_ins.DRGlobal.processObjectsJSON() method. This Connect API removes the dependency on the managed package and provides up to 60% better performance for Data Mapper calls from an Apex class compared to the previous method.
products:
  - Omnistudio
release: "264"
---
# Omnistudio Data Mapper Calls From Apex

Starting with Summer’ 25, to call a Data Mapper from Apex, call the ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput) Connect API specifying the name of the Data Mapper and the input data that it requires. This API replaces the vlocity\_ins.DRGlobal.processObjectsJSON() method. This Connect API removes the dependency on the managed package and provides up to 60% better performance for Data Mapper calls from an Apex class compared to the previous method.

![Important](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio-264-0-0-production-enus/f526eaa8-ae05-487a-8944-4bb99b0b78ac/images/icon_important.png)

Important The performance figures in this document are provided for informational purposes only and are based on internal validation and testing under specific conditions. Actual results may vary depending on your component design, production environment, and other factors. These figures provide ‌general guidance and aren't a guarantee of performance.

Specify the input as follows:

- For a JSON object, use `Map<String, Object>`. Set the String to the JSON key and the Object to the JSON value.
- For an array of JSON objects, use `List<Map<String, Object>>`. Set the String to the JSON key and the Object to the JSON value.
- As an alternative, you can specify the input as a string containing the JSON input required by the Data Mapper.

For details about the methods of the DRGlobal class, which offer multiple ways to call Data Mappers, see [DRGlobal Class and Methods](https://help.salesforce.com/s/articleView?id=xcloud.os_drglobal_class_and_methods_47814.htm&release=264.0.0&type=5 "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.").

## Data Mapper Extract or Transform Example

To process the results returned by a Data Mapper extract or transform in Apex, deserialize the output to a `Map<String, Object>` or `List<Map<String, Object>>`.

```
/* Specify Data Mapper extract or transform to call */
String bundleName = 'DataMapperName'; 


/* Populate the input JSON */
Map<String, Object> objectList = new Map<String, Object>{'MyKey'=>'MyValue'}; 


/* Call the Data Mapper */
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 = null;
options.shouldSendLegacyResponse = true;
apexInput.options = options;
ConnectApi.DataMapperExecuteOutputRepresentation output = ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, apexInput);

/* Process the results returned by a Data Mapper Extract or Transform */
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('response'));
}
```

## Data Mapper Load Example

Data Mapper loads return JSON containing data about the Salesforce objects that were created or updated by the operation. To process the results returned by a Data Mapper load, deserialize the output to a map. From the resulting map, you can extract data about the objects that were created and any errors that occurred. The Data Mapper load example below shows how to access this data from the result map.

```
String objectList = '{"accountName":"Vlocity", "contractCode":"SKS9181"}';

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'));

/* 
Process the results of the load: these methods return details about objects affected by the Data Mapper Load, in addition to any errors that occured 
*/

Map<String, Object> createdObjectsByType = (Map<String, Object>)resultMap.get('createdObjectsByType'); 
Map<String, Object> createdObjectsByTypeForBundle = (Map<String, Object>)createdObjectsByType.get('bundleName');
Map<String, Object> createdObjectsByOrder = (Map<String, Object>)resultMap.get('createdObjectsByOrder');
Map<String, Object> errors = (Map<String, Object>)resultMap.get('errors');
Map<String, Object> errorsByField = (Map<String, Object>)resultMap.get('errorsByField');
List<Object> errorsAsJson = (List<Object>)outerMap.get('errorsAsJson'); // Returns input JSON plus per-node errors
```

## Data Mapper Load Example with the bulkUpload Parameter

This example code passes the bulkUpload parameter to a Data Mapper Load.

```
String objectList = '[{"ProductCode__c": 11050665},{"ProductCode__c": 11070100}]'; // replace this with the input for your Data Mapper Load
String bundleName = 'DRLoadPrice'; // replace this with your Data Mapper name
Map<String,Object> bodyData = new Map<String,Object>();
bodyData.put('bundleName',bundleName);
bodyData.put('objectList',objectList);

List<String> jsonInputData = new List<String>();
jsonInputData.add(bodyData.get('objectList'));

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(bodyData.get('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'));
```