I am using Anypoint Studio 6.1 and Mule 3.8.1.
I have a Boolean field coming in from a CSV file that I want to add code to clean the data e.g. turn "Y", "Yes" into true or otherwise set it to false.
I only want the code to work if the field has a value. If it is '' then I want to ignore it if it is populated then clean the data. I thought adding a when statement would be the answer but it errors in preview. How do I make this a conditional check?
Dataweave code:
(payload filter $$ > 2) map ((payload01 , indexOfPayload01) -> {
({
isPaid: true
}
when payload01.balanced != ''
and ((lower payload01.balanced == 'yes'
or (lower payload01.balanced) == 'y'
or (lower payload01.balanced ) == 'true')
otherwise {
isPaid: false
})
})