Contact Free trial Login

Dynamic Evaluate Component

Available since 4.1

This Core component evaluates an expression that should result in another script, then evaluates that script for a final result. Such behavior allows you to dynamically select the script, instead of hardcoding it through the Transform Message Component.

The script can use any of the usual context variables, such as message, payload,vars, or attributes, but you can also add custom ones by providing a set of key-value pairs.

The following example selects a script from a database through a userId query parameter and stores that script in a userScript variable. The dynamic-evaluate component then accesses the variable to invoke the script so it can add a name variable from a userName query parameter.

Example: XML Configuration of the Flow
<flow name="raise-error-example-flow">
  <http:listener config-ref="HTTP_Listener_Configuration" path="/"/>
  <db:select config-ref="dbConfig" target="userScript">
    <db:sql>#["SELECT script FROM SCRIPTS WHERE ID = $(attributes.queryParams.userId)"]</db:sql>
  <ee:dynamic-evaluate expression="#[vars.userScript]">
    <ee:parameters>#[{name: attributes.queryParams.userName}]</ee:parameters>

Imagine the following scripts stored in the database for entries lsalander and mblomkvist, respectively:

Example: lsalander script
output application/json
  message: "Order " ++ attributes.queryParams.orderId ++ " has been received from " ++ name,
  items: payload.items
Example: mblomkvist script
output application/x-www-form-urlencoded
  message: "Order " ++ attributes.queryParams.orderId ++ " has been received from " ++ name,
  items: payload.items

Sending lsalander as the userId would result in a JSON response, while sending mblomkvist would result in a x-www-form-urlencoded response, essentially allowing the response type to be parameterized per user. In fact, the entire response could be parameterized to each users needs.

Dynamic Evaluate Configuration

Field Value Description Example


DataWeave expression

Specifies the expression to be evaluated into the final script.



DataWeave expression

Specifies key-value pairs that should be bound to evaluate the final script.

#[{joiner: ' and ', id:}]

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub