Evaluate expression DAC
The Evaluate expression dynamic advanced command is part of the variable commands. Use this command to perform complex mathematical operations, manipulate text, and evaluate data. This command can return results as numerical values, text, or logical outcomes like True or False. Drag it into a wizard from the Advanced commands view in the Nintex Wizard Editor to use it.
Before you begin:
Learn how to navigate the Nintex Wizard Editor of the Studio.
Understand how to create wizards and use advanced commands.
Understand variables.
Learn how to customize error handling within an advanced command.
Understand how to configure wizard fallbacks.
Use the Evaluate expression command to enhance your automation in various scenarios:
-
Perform calculations: Handle basic arithmetic and more complex mathematical operations.
-
Operations: Perform addition, subtraction, multiplication, division, and modulus (remainder) calculations. For example, you can calculate (15 * 16) + 2 and store the result in a variable.
-
Functions:
-
LEN: Returns the length of a string, including spaces.
-
SUBSTRING: Extracts a portion of a string based on the starting position and length.
-
TRIM: Removes spaces, tabs, and enters from the beginning and end of a string.
-
-
-
Evaluate conditions: Check whether certain conditions are true or false.
-
Logical Conditions: Use =, <>, <, >, <=, >=, AND, OR, and LIKE to evaluate conditions and return True or False.
-
Functions:
-
IIF: Returns one of two values based on whether a condition is true or false.
-
-
-
Manipulate text: Trim spaces, extract substrings, and determine the length of a string.
-
Combine expressions: Use logical operators to merge multiple expressions into one complex evaluation.
To effectively use the Evaluate expression command, understand the basic parts and rules for creating expressions. These include constants, variables, operators, and functions. These elements define the logic and actions of the command.
Constants
-
Use single quotes to define text strings as constants (e.g., 'ProductName'). This treats the text as a string rather than a variable or code.
-
If your text includes a single quote (e.g., in a possessive form like 'John's Report', add an extra single quote where the single quote appears (e.g., 'John''s Report'). This ensures the quote becomes part of the text, preventing any syntax errors.
-
Enter numeric constants without additional characters (e.g., 5000) to ensure the number processes correctly in calculations or comparisons.
-
Place a number within single quotes to treat it as text (e.g., '5000') to prevent the number from participating in calculations, which is crucial for identifiers like product codes or account numbers.
-
Use decimals in numeric values when needed (e.g., 2.71828) to ensure precision in calculations or when working with values like prices or measurements.
-
Avoid including commas or currency symbols in numeric values (e.g., use 1000 instead of 1,000 or $1000). This prevents errors in calculations since commas might separate digits incorrectly, and currency symbols could convert the value into text.
Variables
-
Use dollar signs for text variables, e.g., $TextVariable$.
-
Use number signs for numeric variables, e.g., #NumericVariable#.
Operators
Operator Type | Operator | Description |
---|---|---|
Arithmetic operators | + | Addition |
- | Subtraction | |
* | Multiplication | |
/ | Division | |
% | Modulus (returns the remainder when dividing the first value by the second) | |
Boolean operators | AND | Logical AND |
OR | Logical OR | |
Comparison operators | = | Equals |
<> | Does not equal | |
< | Less than | |
> | Greater than | |
<= | Less than or equal to | |
>= | Greater than or equal to | |
LIKE |
Works similarly to equals and allows wildcard characters (*) and (%) for flexible pattern matching in strings. Below are key details on how to use the LIKE operator:
|
|
String operations | + |
Use the + character to concatenate (link together) text strings. Example: 'Product' + ' ' + $productName$ This example joins three different parts:
Result: Product Laptop if $productName$ = "Laptop". |
AND, OR |
Create complex expressions by linking clauses with AND and OR operators.
Example: ($category$ = 'Electronics' OR $category$ = 'Home Appliances') AND $availability$ = 'In Stock'
Result: The expression returns True if:
|
Functions
Function Type | Description | Syntax | Arguments | Example |
---|---|---|---|---|
LEN | Returns the length of a string, including spaces. | LEN(expression) | expression = the string to be evaluated. |
Variable: $productName$ = "Wireless Mouse" Expression: LEN($productName$) Result: 14 |
IIF | Returns one of two values based on the result of a logical expression. | IIF(expression, if_true, if_false) |
|
Variable: #stockLevel# = 15 Expression: IIF(#stockLevel# >= 10, "In Stock", "Low Stock") Result: In Stock |
TRIM | Removes spaces, tabs, and enters from both ends of an expression. | TRIM(expression) | expression = the expression to trim. |
Variable: $customerName$ = [space][tab]Emily Smith[enter] Expression: TRIM($customerName$) Result: Emily Smith |
SUBSTRING | Returns a substring of a specified length starting at a given point in the string. | SUBSTRING(expression, start, length) |
|
Variable: $orderDetails$ = "Order ID: 12345, Product: Laptop, Quantity: 2" Expression: SUBSTRING($orderDetails$, 11, 5) Result: 12345 |
In the Nintex Wizard Editor, search for the Evaluate expression command and drag it into your steps. Use the table below to configure each field and understand the necessary settings:
Field | Description | What to do |
---|---|---|
Evaluate the expression | The calculation or expression to perform or evaluate. This can include mathematical operations, text manipulations, or logical evaluations. | Enter the calculation you want to perform or the expression you want to evaluate for validity. |
Return the result |
The variable to store the result of the evaluation. Depending on the expression, the result may be a number (e.g., 123), text (e.g., "Result Text"), or a boolean (True or False). |
Enter the name of the result variable. Use descriptive names for result variables to indicate the data they contain (e.g., StringLength). |
Follow these best practices when using the Evaluate expression command:
-
Identify whether you’re working with text, numbers, or boolean values before creating expressions.
-
Use parentheses to control the order of operations, e.g., 120/(10+2) = 10.
-
Choose clear variable names to easily understand the command’s output, especially in complex wizards.
-
Run sample data through your expressions to confirm the output matches your expectations.
This example shows how to perform a calculation and evaluate a condition, returning the result in a variable.
-
Add the Evaluate expression command to your wizard and complete the following fields:
-
Evaluate the expression: Enter the expression 15*16*2.
-
Return the result in variable: Enter a descriptive name for the variable (e.g., results).
-
-
Add another Evaluate expression command and complete the following fields:
-
Evaluate the expression: Enter the expression 15*16*2 = 500.
-
Return the result in variable: Enter a descriptive name for the variable (e.g., valid).
-
-
Use the View variable list command to verify the command works as intended.