Reputation: 467
I have a payload as list of maps and another flow variable as map.
I wanted to add flow variable to payload list. I tried using this expression #[payload.addAll(flowVars['entitlement'])]
in expression component. But it sets the payload to boolean value true.
Upvotes: 1
Views: 8058
Reputation: 92
You can use dataweave transform component and add the elements in various ways like using the ++ operator or use map operator to change the structure as per your requirements.
Upvotes: 0
Reputation: 12943
You set the payload as the value returned by addAll(). It's like doing payload = payload.addAll(flowVars['entitlement'])
in Java addAll()
returns a boolean, that's why your payload becomes true
.
You can use instead:
#[payload.addAll(flowVars['entitlement']); payload)
This will perform your addAll()
operation on your payload and then return this modified payload afterward. ;
allow your to perform multiple expressions in MEL
Upvotes: 0
Reputation: 2415
Use expression component like
<expression-component doc:name="Expression"><![CDATA[payload.addAll(flowVars['entitlement'])]]></expression-component>
Hope this helps.
Upvotes: 1
Reputation: 2832
Try using Set Payload transformer. and add
Upvotes: 0