BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
22 / 278 · Module 2 — Building a Real Mule Flow · filtered: code← prev⊞ allnext →

2.16Saving the Salesforce Account ID

After Account Upsert:

payload[0].id

might be:

001ABCD1234

Set:

vars.salesforceAccountId

to:

#[payload[0].id]

Now transform Contact:

%dw 2.0
output application/java
---
[
    {
        FirstName: vars.originalCustomer.contact.firstName,
        LastName: vars.originalCustomer.contact.lastName,
        Email: vars.originalCustomer.contact.email,
        AccountId: vars.salesforceAccountId
    }
]

Now Salesforce understands:

This Contact belongs to this Account.