Transform Json format as below
Input:
["100555809","100000001"]
into the following format so that it can be used in the SOQL query by assigning the transformed output some flow variable in salesforce connector.
Output:
('100555809','100000001')
Transform Json format as below
Input:
["100555809","100000001"]
into the following format so that it can be used in the SOQL query by assigning the transformed output some flow variable in salesforce connector.
Output:
('100555809','100000001')
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.