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
filterandmap?”
Answer:
filter
→ chooses records
map
→ transforms records