Can someone please let me know how to concatenate multiple values in mule?
Something like,
#[payload.getPayload()].concat(#[getSubject()])
In DataWeave 2.0, concatenation can be achieved by using the ++ (plus plus) function. However, there are two additional syntax options to concatenate objects and one to concatenate strings in DataWeave. Concatenation is when you link two strings, objects, data types etc together in a chain or series.
In Mule 4, you can easily do this with DataWeave (using the Transform Message component). Just add multiple targets and select "Variable" as output.
We don't have the feature to comment multiple lines in Dataweave, but we can comment single line by using `//` operator.
I assume you are using Mule 3.3.x or above. If so you can use Mule Expression Language(MEL).
One example using MEL is:
#['Hello' + 'World']
Or MEL also allows you to use standard Java method invocation:
#[message.payload.concat(' Another String')]
Cheat sheet on MEL
MULE 4 Update
For Mule 4. Dataweave 2.0 is the main expression language:
Simple concat:
#['Hello' ++ ' World']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With