BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
93 / 1048 · Module 4 — Salesforce Connector← prev⊞ allnext →

4.9UPSERT — probably your favorite operation

Suppose upstream gives us:

customerId = CUST-10042

Salesforce field:

External_Customer_ID__c

Then:

Upsert Account
External ID:
External_Customer_ID__c

Input:

[
    {
        External_Customer_ID__c:
            payload.customerId,

        Name:
            payload.companyName
    }
]

Salesforce effectively does:

Does External_Customer_ID__c = CUST-10042 exist?

YES
 ↓
UPDATE

NO
 ↓
INSERT

The current MuleSoft connector documentation explicitly says that Upsert creates or updates using a custom field to identify existing records and recommends it over Create in many cases to avoid unwanted duplicates.