Skip to content

Generic Expression Evaluator#

The Generic Expression Evaluator evaluates mathematical and logical expressions using the mathjs engine. It allows users to perform arithmetic, logical comparisons, and complex mathematical operations on input data, producing computed results dynamically.

Generic Expression Evaluator screenshot

Note

This task results from a split of the Expression Evaluator task. It can be used along with Regular Expression Evaluator and XPath Expression Evaluator.

Workflows#

Data Flow Control Flow

Inputs#

Name Data Type Description
<custom list> <custom> Defines the input values used in the evaluation
Activate any Triggers task execution

Outputs#

Name Data Type Description
<custom list> <custom> Defines the output values generated by the evaluation
Success Boolean Returns true if the task completes successfully
Error Error Contains information about any error that occurs

Settings#

The General tab includes standard task settings and the following parameters:

Name Data Type Values Default Value Description
Evaluator Behavior enum EvaluateAll
EvaluateUntilTrue
EvaluateAll Defines whether all expressions are evaluated or evaluation stops after the first true result
Clear Inputs Boolean false When enabled, clears input values after task execution

Generic Expression Evaluator General Settings screenshot

The Inputs Tab includes the following settings:

Name Data Type Description
Name String Input Name
Friendly Name String The displayed input name
Type Long
Decimal
DateTime
Boolean
String
Integer
Defines the data type of the input
Default Value any Default value assigned to the input parameter
Required Boolean Indicates if input is required

Generic Expression Evaluator Input Settings screenshot

The Outputs Tab includes the following settings:

Name Data Type Description
Name String Output Name
Friendly Name String The displayed output name
Type Long
Decimal
DateTime
Boolean
String
Integer
Defines the data type of the output
Expression Text Expression applied to the input data

Generic Expression Evaluator Output Settings screenshot

Behavior#

The Generic Expression Evaluator task uses the mathjs engine, a JavaScript-based library for mathematical and logical computation, as well as some native JavaScript functions.

The task runs when the Activate input is triggered and every input defined on the Inputs tab has a value: required inputs must receive one, and optional inputs can fall back to their default value. Each output expression can reference any input by its name, and the result is converted to the Type configured for the output.

The Evaluator Behavior setting defines how the configured output expressions are processed:

  • EvaluateAll (default): Evaluates every configured expression and emits each result on its output.
  • EvaluateUntilTrue: Evaluates the expressions in the configured order and stops at the first expression whose result converts to true, emitting only that output.

When the Clear Inputs setting is enabled, the received input values are cleared when the task executes, so the next execution requires new values instead of reusing the previous ones.

Remarks#

The Generic Expression Evaluator provides flexible operations for transforming input data. While mathjs supports many JavaScript-like functions, it is not a full JavaScript engine; some native JavaScript code may not execute as expected.

Examples#

Add two values#

Configure the Inputs tab with two inputs:

Name Type Required
value Integer Yes
increment Integer Yes

Configure the Outputs tab with one expression:

Name Type Expression
result Integer value + increment

When the value input receives 10 and the increment input receives 2, the result output emits 12. Functions such as min, max, round, abs, or pow can be used the same way, for example round(value, 1).

Compare strings with compareText#

Configure the Inputs tab with one input:

Name Type Required
checksum String Yes

Configure the Outputs tab with one expression:

Name Type Expression
isValid Boolean compareText(checksum, "expectedValue") == 0

The mathjs compareText function compares two strings and returns 0 when they are equal, so the isValid output emits true only when the checksum input receives expectedValue. The task also overrides the mathjs equal and unequal functions so that string values are compared as text.

Stop at the first true expression#

Set the Evaluator Behavior setting on the General tab to EvaluateUntilTrue. Configure the Inputs tab with one required Integer input named value and the Outputs tab with two expressions:

Name Type Expression
isHigh Boolean value > 9
isLow Boolean value <= 9

When the value input receives 10, the isHigh expression evaluates to true, so the isHigh output emits true and the evaluation stops. The isLow expression is never evaluated and its output does not emit.