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

3.29A more realistic reusable function

Say several fields need defaults:

%dw 2.0
output application/json

fun clean(value) =
    trim(value default "")

---
{
    FirstName: clean(payload.firstName),
    LastName: clean(payload.lastName),
    Company: clean(payload.company)
}

This is much cleaner than performing each manipulation through Mule processors.