BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
5 / 81 · Module 3 — DataWeave 2.0 Crash Course · filtered: interview← prev⊞ allnext →

3.9Real Salesforce bulk mapping

Incoming:

{
  "customers": [
    {
      "id": "C001",
      "name": "Acme",
      "email": "info@acme.com"
    },
    {
      "id": "C002",
      "name": "Widget Inc",
      "email": "info@widget.com"
    }
  ]
}

Transform:

%dw 2.0
output application/java
---
payload.customers map (customer) -> {
    External_Customer_ID__c: customer.id,
    Name: customer.name,
    Email__c: customer.email
}

Result sent to Salesforce Connector:

[
  {
    "External_Customer_ID__c": "C001",
    "Name": "Acme",
    "Email__c": "info@acme.com"
  },
  {
    "External_Customer_ID__c": "C002",
    "Name": "Widget Inc",
    "Email__c": "info@widget.com"
  }
]

If an interviewer asks you to map an array, map is your immediate answer.