Search code examples
muletransformer-model

Adding flow variable to Mule map payload


What am I doing wrong here? I want to set the payload of a Mule message to a map containing multiple values, one of them the contents of a flow variable.

<set-variable variableName="myVariable" value="foo"/>
<set-payload value="#[['STATUS':'OKAY','NEXT':'Test','TEXT':flowVars['myVariable']]]"/>
<logger level="INFO" message="#[payload]"/>

The output of this is:

{STATUS=OKAY, NEXT=Test}

I was expecting:

{STATUS=OKAY, NEXT=Test, TEXT=foo}

I know I can do this with a series of expression transformers but, if I want to use this kind of notation, why isn't it pulling the value of the flow variable in?

Edit: to remove typo in source code This solved the problem as noted by Ryan's answer below.


Solution

  • It seems you have unbalanced braces. There is an unnecessary brace after 'Test'.

    Should be:

    <set-payload value="#[['STATUS':'OKAY','NEXT':'Test','TEXT':flowVars['myVariable']]]"/>