Assuming your input is the payload and you want a string as output, you'll want to use map
to wrap all your IDs in single quotes, then joinBy
to join them into a single string. Finally, you'll wrap the result in parenthesis:
%dw 1.0
%output application/java
%var ids = payload
// Wrap ids in single quotes and join them into a string
%function formatIds(ids)
ids
map ((id) -> "'$(id)'")
joinBy ","
%function transformForSOQL(ids)
"($(formatIds(ids)))"
---
transformForSOQL(ids)
Not sure if SOQL is exposed to the same vulnerabilities, but if it is, be careful of "SOQL" injection when generating dynamic query values like this.