BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
3 / 81 · Module 2 — Building a Real Mule Flow · filtered: interview← prev⊞ allnext →

2.6Transform Message

Now we transform our API contract into Salesforce's contract.

Input:

{
  "customerId": "CUST-10042",
  "companyName": "Acme Corporation",
  "phone": "305-555-1234",
  "billing": {
    "city": "Miami",
    "state": "FL"
  }
}

DataWeave:

%dw 2.0
output application/java
---
[
    {
        External_Customer_ID__c: payload.customerId,
        Name: payload.companyName,
        Phone: payload.phone,
        BillingCity: payload.billing.city,
        BillingState: payload.billing.state
    }
]

Notice:

[
   {
      ...
   }
]

Why an array?

Because Salesforce Connector operations commonly operate on collections of records, even when you're sending only one.

MuleSoft's own Salesforce examples similarly transform incoming data into an application/java array before calling Salesforce.