I am wanting to invoke a function on payload which is a Java pojo to set a value.
<set-variable variableName="name" value="xyz" doc:name="Variable"/>
<foreach doc:name="For Each">
<expression-transformer expression="#[payload.setEventId(flowVars['name'])]" doc:name="Expression"/>
<logger message="#[payload.getEventId()]" level="INFO" doc:name="Logger"/>
</foreach>
But this is giving me error. Root Exception stack trace: org.mule.api.transformer.TransformerException: Expression Evaluator "null" with expression "payload.setEventId(flowVars['name'])" returned null but a value was required.
The
expression-transformer
replaces the current payload with the value returned by the expression. I'm guessingsetEventId
is void thus the expression returnsnull
, hence the exception.Use an
expression-component
instead: