Loading
Classe e metodi DRGlobal

Classe e metodi DRGlobal

Utilizzare l'API Connect ConnectApi.OmniDesignerConnect.executeDataMapper(bundleName, ApexInput) per chiamare i mappatori di dati da Apex tramite la classe Apex DRGlobal. A partire dal rilascio Summer '25, sostituire i metodi esistenti nelle classi Apex DRGlobal con l'API Connect.

Elaborazione di un elenco di oggetti stringa JSON con un mappatore di dati specificato

objectList deve essere una stringa JSON.

API Connect Metodo esistente (sostituisci con API Connect)
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);

Elaborazione di un elenco di sObject con un mappatore di dati specificato

API Connect Metodo esistente (sostituisci con API Connect)

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)

Questa firma, che non richiede un DRName, è solo per un 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
)

additionalInfo è una mappa che si applica a ogni SObject, ad esempio ai dati aggiuntivi per l'elaborazione.


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)

additionalInfo è una mappa che si applica a ogni SObject, ad esempio ai dati aggiuntivi per l'elaborazione.

Elaborare un elenco o una mappa di oggetti, ignorando le regole di condivisione, con un mappatore di dati e impostazioni internazionali specificati

Questi metodi ignorano le regole di condivisione, il che garantisce che il Data Mapper invocato sia privato. Vedere Regole di condivisione nella Guida di Salesforce.

API Connect Metodo esistente (sostituisci con API Connect)

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

}
Nota
Nota Gli utenti devono disporre delle autorizzazioni appropriate per eseguire 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'));
}
Nota
Nota Gli utenti devono disporre delle autorizzazioni appropriate per eseguire Data Mapper.

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

Elaborare un elenco o una mappa di oggetti con un mappatore di dati e impostazioni internazionali specificati, tenendo presenti le regole di condivisione

API Connect Metodo esistente (sostituisci con API Connect)

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
)

Caricare i dati con il parametro bulkupload

Questo metodo può chiamare solo un Data Mapper Load. Nessun altro metodo Apex può passare il parametro bulkUpload a un Data Mapper. Vedere OmniStudio Data Mapper Calls From Apex.

API Connect Metodo esistente (sostituisci con API Connect)

Elaborazione sincrona:


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

Ecco l'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} ....... )}

Si verifica una mancata corrispondenza nell'output durante l'elaborazione sincrona. Eseguire i passaggi seguenti per ottenere la corrispondenza esatta dell'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)

Approccio esistente per l'elaborazione sincrona


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));
L'API Connect per caricare i dati in modo asincrono utilizzando il parametro 'bulkupload' non è disponibile.

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

Elaborazione di una stringa XML con un data mapper specificato

API Connect Metodo esistente
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)
 
Caricamento
Salesforce Help | Article