Skip to content

Instantly share code, notes, and snippets.

@jrichardsz
Forked from felipebizz/setVariable.groovy
Created January 5, 2020 13:22
Show Gist options
  • Save jrichardsz/84fc493c719bd43d036f676fbfa8b76a to your computer and use it in GitHub Desktop.
Save jrichardsz/84fc493c719bd43d036f676fbfa8b76a to your computer and use it in GitHub Desktop.
[Mule] Set variable value inside Groovy
<flow name="get:/setVariable:api-config">
<set-variable variableName="username" value="" doc:name="username"/>
<scripting:component doc:name="Groovy">
<scripting:script engine="Groovy">
<![CDATA[
String value = 'felipe'
message.setInvocationProperty('username', value)
]]></scripting:script>
</scripting:component>
</flow>
//More options of set Value inside Groovy
message.setInvocationProperty('myFlowVariable', 'value') // sets a flow variable, like <set-variable/>
message.setOutboundProperty('myProperty', 'value') // sets an outbound message property, like <set-property/>
message.setProperty('myInboundProperty', 'value', PropertyScope.INBOUND) // sets an inbound property
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment