BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
7 / 1048 · Module 1 — MuleSoft Mental Model← prev⊞ allnext →

1.7`vars`

Variables let you preserve information while the payload changes.

This solves the problem I just described.

Imagine:

Original request
       ↓
Salesforce Query
       ↓
payload now contains query result

But you still need the original request.

Before querying Salesforce:

Set Variable
customer = payload

Then later:

vars.customer

still contains:

{
  "firstName": "John",
  "lastName": "Smith"
}

even though:

payload

contains the Salesforce query response.

Interview phrase

A very good sentence to use:

“Since connector operations frequently replace the current payload with their result, I use variables to preserve data that I'll need later in the flow rather than relying on payload remaining unchanged.”

That sounds like somebody who has actually built Mule applications.