MRavindran
MRavindran

Reputation: 467

mule: how to add value to payload array list

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

Answers (4)

Srinivas
Srinivas

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

Pierre B.
Pierre B.

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

AnupamBhusari
AnupamBhusari

Reputation: 2415

Use expression component like

<expression-component doc:name="Expression"><![CDATA[payload.addAll(flowVars['entitlement'])]]></expression-component>

Hope this helps.

Upvotes: 1

Mahesh_Loya
Mahesh_Loya

Reputation: 2832

Try using Set Payload transformer. and add

[payload.addAll(flowVars['entitlement']) as value.

Upvotes: 0

Related Questions