I will let the code do the explanation.
Dataweave gives errors:
Unable to resolve reference of when
Unable to resolve reference of otherwise
Input Message: An array of objects. Though I have given only 1 object here.
[{
"Field1" : 12345,
"field2" : 10
}]
%dw 2.0
output application/json
---
payload map {
"test" : $.Field1 when $.field2 >= 1 otherwise ""
}
Nadeem there is no <expression> when <condition> otherwise <expression>
in DW 2.0. Use if (condition) <then_expression> else <else_expression>
instead.
So your code will be as follows:
%dw 2.0
output application/json
var data = [{
"Field1" : 12345,
"field2" : 10
}]
---
data map {
test : if ($.field2 >= 1) $.Field1 else ""
}