---
schema_version: "1"
id: ffe0ad5049fea0fad7cc4e9d12c8d5c95261642beeeaea5be382c58d15c87dd4
title: Omnistudio Data Mapper Calls From Apex (Managed Package)
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.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_dataraptor_calls_from_apex.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 9186c4e3abb4408fb959cc99cb1feefc16a2d2197e784465a6c475be3435a090
description: For the managed package runtime, to call a Data Mapper from Apex, call the vlocity_ins.DRGlobal.processObjectsJSON() method, specifying the name of the Data Mapper and the input data that it requires.
products:
  - Omnistudio
release: "264"
---
# Omnistudio Data Mapper Calls From Apex (Managed Package)

For the managed package runtime, to call a Data Mapper from Apex, call the `vlocity_ins.DRGlobal.processObjectsJSON()` method, specifying the name of the Data Mapper and the input data that it requires.

![Managed Package app icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/resources-global/_corporate/images/managedpackageicon.png) This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see [Omnistudio Help](https://help.salesforce.com/s/articleView?id=xcloud.os_omnistudio_standard.htm&language=en_US).

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 (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_drglobal_class_and_methods.htm&release=264.0.0&type=5 "For the managed package runtime, the DRGlobal class provides multiple methods for calling Omnistudio Data Mappers from Apex.").

## Data Mapper Extract or Transform Example

To process the results returned by a Data Mapper extract or transform in Apex, use the `toJsonList()` method to deserialize the output to a `Map<String, Object>` or `List<Map<String, Object>>`. To determine which type to use, check the data type of the response.

```
/* Specify Data Mapper extract or transform to call */
String DRName = 'DataMapperName'; 
/* Populate the input JSON */
Map<String, Object> myTransformData = new Map<String, Object>{'MyKey'=>'MyValue'}; 
/* Call the Data Mapper */
vlocity_ins.DRProcessResult result = vlocity_ins.DRGlobal.process(myTransformData, DRName); 
/* Deserialize the Data Mapper output for processing in Apex */ 
List<Map<String, Object>> myTransformResult = (List<Map<String, Object>>)result.toJsonList(); 
```

## 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 dataJson = '{"accountName":"Vlocity", "contractCode":"SKS9181"}';
vlocity_ins.DRProcessResult result = vlocity_ins.DRGlobal.processObjectsJSON(dataJson, 'Create Contracts');
Map<String, Object> resultMap = result.convertToMap();
System.debug(JSON.serialize(resultMap));
/* 
Process the results of the load: these methods return details about objects affected by the Data Mapper load, plus any errors that occured 
*/
Map<String, Object> createdObjectsByType = (Map<String, Object>)resultMap.get('createdObjectsByType'); 
Map<String, Object> createdObjectsByTypeForBundle = (Map<String, Object>)createdObjectsByType.get('Create Contracts');
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');
Map<String, Object> errorsAsJson = (Map<String, Object>)resultMap.get('errorsAsJson'); // Returns input JSON plus per-node errors
```

## Data Mapper Load Example with the bulkUpload Parameter

Use the processPost method if you need to pass 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 DR name
String bulkUpload = 'true';
Map<String,Object> bodyData = new Map<String,Object>();
bodyData.put('bundleName',bundleName);
bodyData.put('bulkUpload',bulkUpload);
bodyData.put('objectList',objectList);
vlocity_cmt.DRGlobal.processPost(bodyData);
```