BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
81 / 1048 · Module 3 — DataWeave 2.0 Crash Course← prev⊞ allnext →

3.38A DataWeave interview exercise

Interviewer gives you:

{
  "customers": [
    {
      "id": "1",
      "name": "Acme",
      "active": true
    },
    {
      "id": "2",
      "name": "Old Inc",
      "active": false
    },
    {
      "id": "3",
      "name": "Widget",
      "active": true
    }
  ]
}

and asks:

Transform active customers for Salesforce.

You should be able to produce approximately:

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

If you can write that without panicking, you're already in decent shape.