Loading
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Create Interface Objects for a Data Mapper Load

          Create Interface Objects for a Data Mapper Load

          Provide external data, such as a CSV file, as an input to a Data Mapper Load. The external data can be imported into an interface object, which is a custom Salesforce object using a data import tool. Then, map the fields from the custom object to the target Salesforce records using a Data Mapper Load. When you load data to a Salesforce custom object, it fires an Apex trigger that calls a Data Mapper Load. The Data Mapper takes data from the interface object and writes the resulting data to other Salesforce record objects.

          Interface object for Data Mapper Load

          You can load data to a Salesforce custom object by using Salesforce's Data Import Wizard or a tool such as the Salesforce Data Loader, Informatica, or Talend.

          1. In Salesforce, create a custom object and add fields corresponding to the data in the external source.
            1. Add these string fields to the custom object:
              • DMError (Data Type: Long Text Area)
              • DMProgressData (Data Type: Long Text Area)
              • DMName (Data Type: Text): This field is required.
                Note
                Note

                In Omnistudio for Managed Packages, DRBundleName is a required field.

              • DMStatus (Data Type: Long Text Area)

              These fields are reserved by Data Mappers for internal use.

            2. Add fields corresponding to the data in the external source.
          2. Create an Apex class DMInterfaceObjectFuture.
            1. From Setup, find and select Apex Classes.
            2. Create a new Apex class and add this code.
              public class DMInterfaceObjectFuture {
              @future(callout=true)
              public static void call(String sObjectIdsAsString){
              List<String> sObjectIds = (List<String>)JSON.deserialize(sObjectIdsAsString, List<String>.class);
              ConnectApi.DataMapperInterfaceObjectInput input = new ConnectApi.DataMapperInterfaceObjectInput();
              input.interfaceObjectIds = sObjectIds;
              input.interfaceObjectAPIName = String.valueOf(((Id)sObjectIds.get(0)).getSObjectType());
              ConnectApi.DataMapperInterfaceObjectConnect.executeDataMapperLoadForInterfaceObjects(input);
              }
              }
              
          3. Create a new trigger on the custom object that invokes the Data Mapper Load.
            trigger trigger_name on interface_object_api_name (after insert, after update)
            {
                String orgNamespace = [SELECT NamespacePrefix FROM Organization LIMIT 1].NamespacePrefix;
                String prefix = String.isEmpty(orgNamespace) ? '' : orgNamespace + '__';
                List<String> sObjectIds = new List<String>();
                for (sObject sObj : Trigger.new) {
                   if (Trigger.isUpdate) {
                     if (Trigger.oldMap.get(sObj.Id).get(prefix + 'DMStatus__c') != Trigger.newMap.get(sObj.Id).get(prefix + 'DMStatus__c') ||
                       Trigger.oldMap.get(sObj.Id).get(prefix + 'DMError__c') != Trigger.newMap.get(sObj.Id).get(prefix + 'DMError__c') ||
                       Trigger.oldMap.get(sObj.Id).get(prefix + 'DMProgressData__c') != Trigger.newMap.get(sObj.Id).get(prefix + 'DMProgressData__c') ||
                       Trigger.oldMap.get(sObj.Id).get(prefix + 'DMName__c') != Trigger.newMap.get(sObj.Id).get(prefix + 'DMName__c')) {
                       continue;
                     }
                   }
            
                   sObjectIds.add(sObj.Id);
                }
            
                if (!sObjectIds.isEmpty()) {
                    DMInterfaceObjectFuture.call(JSON.serialize(sObjectIds)); 
                }
            }
          4. Create and configure the Data Mapper Load.
            1. Create a Data Mapper Load with SObject as the input type.
            2. Select the interface object that you created for the input data from the dropdown list.
            3. In the Data Mapper Load, map the interface object fields with the Salesforce records that you want to update.
            4. To verify that your Data Mapper Load can access data in the interface object, load a small amount of test data into the interface object and run the Data Mapper.
          5. Import the external data into the interface object by using the Salesforce bulk load tool or your preferred bulk load tool.

            You can now use interface objects in Data Mappers in the same way as standard Salesforce objects.

            Tip
            Tip

            If you use interface objects regularly, rather than for a one-time bulk load, create a tab for the object to facilitate quick and easy access.

          Create Interface Objects for a Data Mapper Load Example

          1. Create an interface object TestInterfaceObject__c with these fields:
            • Data__c: This is the data field to add custom data.
            • DMStatus__c
            • DMError__c
            • DMProgress
            • DMName__c
          2. Create a Data Mapper Load with the TestInterfaceObject__c object as the input that creates records of Account and Contact.
          3. Configure the Data Mapper Load mapping.
            • TestInterfaceObject__c.Data__c to Account.Name
            • TestInterfaceObject__c.Data__c to Contact.LastName
          4. Create a new record for TestInterfaceObject__c.
            For example, when you add a new record, Account1, in the Data_c field of the interface object, a new Account record with Name = Account1 is created and a new Contact record with LastName = Account1 is created.

            These fields of the TestInterfaceObject__c object are updated:

            • DMStatus__c: {"Account": "success", "Contact": "success"}
            • DMProgressData__c: {"Account": "<created account id>", "Contact": "<created contact id>"}
           
          Loading
          Salesforce Help | Article