BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
71 / 278 · Module 4 — Salesforce Connector · filtered: code← prev⊞ allnext →

4.16Parent → child creation

Let's revisit:

Account
  ↓
Contact

Input:

{
  "customerId": "C001",
  "company": "Acme",

  "contacts": [
    {
      "id": "P001",
      "firstName": "John",
      "lastName": "Smith"
    }
  ]
}

Flow:

Transform Account
      ↓
Upsert Account
      ↓
obtain Salesforce Account.Id
      ↓
Transform Contacts
      ↓
Upsert Contacts with AccountId

Contacts:

vars.original.contacts map (contact) -> {
    External_Contact_ID__c: contact.id,
    FirstName: contact.firstName,
    LastName: contact.lastName,
    AccountId: vars.accountId
}

This is basic Salesforce relationship orchestration.