Map and Transform the Salesforce and Shopify Data to a Single Contact Resource

To move a contact from Salesforce to Shopify, we need to map the Salesforce /Contact object and the Shopify /customer object to a virtual data resource: A a uniform API wrapper around multiple API provider endpoints for given data structures. We'll help you set up a virtual data resource below, but if you want more information take a look at Defining Virtual Data Resources & Transformations.

Step 1. Define a virtual data resource

First define a virtual data resource to represent exactly what you want in a contact. At the end of this step, you'll have a virtual data resource called MyContacts that you can then map Salesforce contacts and Shopify customers to so you can transform their data to what you defined in MyContact.

  1. Navigate to the Virtual Data Resources page. From anywhere in the application, click virtual data resources on the left side.
  2. Click Build a New Virtual Data Resource.

    The Create page shows your new resource with a default organization-level field of id. New Resource from Scratch 

  3. Enter a name for your virtual data resource, such as "myContact".
  4. Add additional fields: In the Organization Level Fields section, click Add.

    Add Fields

  5. Create these fields
    •  Email
    • Last Name
    • First Name
  6. Save the virtual data resource.

Your myContact virtual data resource should look like the example below. Notice that you can now create a transformation on the right side of the page. We'll do that next in Map and Transform Salesforce Contacts.

Resource Defined

Step 2. Map and Transform Salesforce Contacts

Now that you created a virtual data resource, you'll map fields in the Salesforce /Contact object to the virtual data resource. After you map the fields, Cloud Elements transforms the data from Salesforce to match the fields in the virtual data resource.

  1. Click Create New Transformation for "myContact".
  2. The two authenticated element instances that you created in Step 1 appear on the left side of the list.

    Salesforce and Shopify Instances

  3. Click Salesforce Contacts.

    The Salesforce resources — or objects — available to you appear on the right side. Salesforce has many resources, but instead of scrolling through the list we'll search.

    Salesforce Contact Resource

  4. In Search type contact, and then click the Contact resource in the list.

    Back on the Transformations page you see the fields in the myContact virtual data resource on the left and empty fields from the Contact object in Salesforce on the right.

    Map MyContacts

  5. In the first empty field type email. The list filters the fields until you can select the Email field.
  6. Repeat to map the following fields:
    • Salesforce Contact object First Name map to MyContacts FirstName.
    • Salesforce Contact objectid map to MyContacts Id
    • Salesforce Contact objectLast Name map to MyContacts LastName
  7. Your mapping should match the the example below:

    Salesforce Mapping

  8. Save the mapped transformation.

Step 3. Test the Salesforce Contact to MyContacts Transformation

Use the API docs to test the Salesforce Contact to MyContacts transformation.

  1. Switch the API docs on: Click Advanced Settings, switch on Add to API Docs, and then click Save.

    Note: Remove Unmapped Fields is on by default. This ensures that we return only the fields that you identify in your virtual data resource. If it is not on, switch it on.
  2. Test it out: Click Try it out.

    On the Transformed tab, you see a payload with just the fields that you defined in the virtual data resource.Transformed Payload

  3. As a comparison, click Original to see the payload before Cloud Elements transformed it.
  4. Click Cancel to return to the Transformations page.

Now that you mapped the Salesforce /Contact resource to your myContacts virtual data resource, let's map the Shopify /customers resource.

Step 4. Map and Transform Shopify Customers

To map the fields in the Shopify /customer object, we just need to repeat the steps that you just completed for your authenticated Salesforce instance.

  1. From the Transformations page with the mapped Salesforce Contacts instance, click /myContact in the My Resources list.

    The Salesforce Contact instance that you just mapped appears in the Mapped Transformations section.

  2. Click Create New Transformation for "myContact".
  3. This time, click the Shopify Customers instance on the left, and then locate and select the customer resource on the right.
  4. Map the fields to:
    • Shopify customer object Email map to myContacts email
    • Shopify customer object First Name map to myContacts first_name
    • Shopify customer object id map to myContacts id
    • Shopify customer object Last Name map to myContacts last_name
  5. Save the transformation and test it in the API docs.