0

I am working on code migration and in that I am facing problem in migrating expression component of Mule 3 to Mule 4. I tried it using Transform Message Component but I am facing some errors in it. Can someone Please help me to migrate the below Script into Mule 4 using the correct component.

<expression-component doc:name="Expression"><![CDATA[if (flowVars.deletesVar != null) { flowVars.combinedArray.addAll(flowVars.deletesVar); } if (flowVars.insertsVar != null) { flowVars.combinedArray.addAll(flowVars.insertsVar); } if (flowVars.updatesVar != null) { flowVars.combinedArray.addAll(flowVars.updatesVar); } else{ flowVars.combinedArray=[]; }]]></expression-component>
aled
  • 21,330
  • 3
  • 27
  • 34

1 Answers1

0

Mule 3 expression language is MEL which is not supported in Mule 4. You need to migrate the expression to DataWeave 2.0 or migrate it to a Groovy script, or even Java code.

See the migration guide: https://docs.mulesoft.com/mule-runtime/4.4/migration-mel for more information.

Assuming that the 3 variables are arrays or null you can use this script and assign the result to variable combinedArray.

%dw 2.0
output application/java
---
(vars.deletesVar default []) ++ (vars.insertsVar default []) ++  (vars.updatesVar default [])

Note that the logic of the original script seems to be missing some conditions, but this should give a similar result.

aled
  • 21,330
  • 3
  • 27
  • 34