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.

mainImage

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

settings

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

inputs

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

outputs

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.

  • EvaluateUntilTrue: Stops processing when an expression returns a true value and outputs the corresponding result.
  • EvaluateAll: Evaluates all configured expressions and outputs all results.
  • Clear Inputs: When enabled, resets the inputs after task execution.

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.

An expression that fails does not stop the other expressions. The task emits the error on Error only when no output has a result, and then still emits Success.

Examples#

Add a value to an optional increment#

Configure the Inputs tab with a required input and an optional input that has a default value:

Name Type Default Value Required
value Integer Yes
increment Integer 5 No

Configure the Outputs tab with one expression:

Name Type Expression
result Integer value + increment

When the value input receives 7 and the increment input receives no value, the task falls back to the default value 5 and the result output emits 12. If a required input has no value, the task does not evaluate any expression.

Validate a checksum with a text comparison#

Configure the Inputs tab with one input:

Name Type Default Value Required
checksum String 31CA97E5814CF961638F9176ABCF78C68FC04F212B54876E96199FD9F9259436 No

Configure the Outputs tab with one expression:

Name Type Expression
isValid Boolean compareText(checksum, '31CA97E5814CF961638F9176ABCF78C68FC04F212B54876E96199FD9F9259436') == 0

When the checksum input receives a value equal to the expected literal, the isValid output emits true. The mathjs compareText function compares two strings and returns 0 when they are equal. The task also overrides the mathjs equal and unequal functions so that, for example, equal(left, right) compares string inputs 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 input:

Name Type Default Value Required
value Integer Yes

Configure the Outputs tab with two expressions:

Name Type Expression
first Boolean value > 5
second Boolean value / 0

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