I am trying to filter out vales matching a variable using dataweave.
result = {
"drives": [{
"id": "0AEBByqXZ0xb4Uk9PVA",
"name": "QA-zz-SFJobs-Contacts"
}, {
"id": "0AC_FdkeL63mHUk9PVA",
"name": "QA"
}]
}
above is my payload.
Am trying below code
%dw 2.0
output application/json
---
{
drives: payload.result.drives[0] filter ((item, index) -> item.name == "QA")
}
which gives me error
error:
You called the function 'Value Selector' with these arguments: 1: String ("{"drives":[{"id":"0AEBByqXZ0xb4Uk9PVA","name":"QA-zz-SFJobs-Contact...) 2: Name ("drives")
But it expects one of these combinations: (Array, Name) (Array, String) (Date, Name) (DateTime, Name) (LocalDateTime, Name) (LocalTime, Name) (Object, Name) (Object, String) (Period, Name) (Time, Name)
5| drives: payload.result.drives[0] filter ((item, index) -> item.name == vars.folderName) ^^^^^^^^^^^^^^^^^^^^^ Trace: at filter (line: 5, column: 13) at main (line: 5, column: 38)" evaluating expression: "%dw 2.0 output application/json
{ drives: payload.result.drives[0] filter ((item, index) -> item.name == vars.folderName) }".
Expected output:
{ "id": "0AC_FdkeL63mHUk9PVA", "name": "QA" }
how can i achieve this?