BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
20 / 1048 · Module 2 — Building a Real Mule Flow← prev⊞ allnext →

2.1Our requirement

Assume another system sends this:

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

Our Mule API:

POST /customers
Content-Type: application/json

needs to create or update this Salesforce Account.

Salesforce representation:

{
  "External_Customer_ID__c": "CUST-10042",
  "Name": "Acme Corporation",
  "Phone": "305-555-1234",
  "BillingCity": "Miami",
  "BillingState": "FL"
}

We're going to use:

External_Customer_ID__c

as the Salesforce External ID.

Therefore:

customer exists → UPDATE
customer doesn't exist → INSERT

using one operation:

UPSERT

Salesforce Connector's Upsert operation is specifically designed to create or update objects based on a custom field; MuleSoft recommends it over blind create in many cases to avoid duplicates.