BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
15 / 18 · Module 18 — Interview Coding Scenarios · filtered: cheatsheet← prev⊞ allnext →

18.5Scenario 4 — Filter and map

Prompt:

“Only send active customers to Salesforce.”

Input:

[
  {
    "id": "C001",
    "name": "Acme",
    "active": true
  },
  {
    "id": "C002",
    "name": "Old Corp",
    "active": false
  }
]

Write:

%dw 2.0
output application/java
---
payload
    filter (customer) -> customer.active == true
    map (customer) -> {
        External_Customer_ID__c: customer.id,
        Name: customer.name
    }

If they ask you:

“What's the difference between filter and map?”

Answer:

filter
→ chooses records

map
→ transforms records