evaluation

The evaluation task replaced the decision task deprecated in the Gen 2 workflow canvas for 2023.2. See the Breaking Change: Decision Task Replaced.

The evaluation task controls workflow execution paths based on runtime conditions. Use this task to compare values and determine which path your workflow should follow.

When the task’s conditions are met, the task outputs true and execution continues through any success transitions. Otherwise, the task outputs undefined and execution continues through any failure transitions.

This page covers setting the task condition, constructing evaluations, and using operators with different data types.

Output behavior changes in Platform 2023.1 and later

If you’re migrating workflows from Platform 2022.1 to Platform 2023.1 or later, be aware of a change in how the evaluation task displays its output when the fail path is taken.

VersionFail path output
Platform 2022.1Returns "return_value": "null"
Platform 2023.1 and laterReturns nothing (field is absent or empty)

This change affects only how the outcome appears in the job/task view and API responses, not how your workflow executes. When validating migrated workflows, check the transition path to confirm whether the success or fail path was taken, rather than relying on the return value field.

Type inference and coercion

By default, the evaluation task automatically performs type inference and coercion:

  1. First operand — If the first operand can be parsed from a string into another type, the task converts it automatically. For example, the string "500" is converted to the number 500.
  2. Second operand — The task attempts to convert the second operand to match the first operand’s type. If conversion isn’t possible, the evaluation rule fails.

Enable strict types

You can disable type coercion by enabling Strict Types mode. When enabled, the task compares operands exactly as provided without any type conversion.

1

Open the task configuration window

Open the task configuration window.

2

Open the Options tab

Click the Options tab.

3

Enable Strict Types

Enable the Strict Types toggle.

The following example shows how the != operator behaves differently based on the strict types setting:

Operand AOperatorOperand BStrict TypesResultExplanation
"500"!="Hello"Offfalse (fails)"500" is coerced to 500, then "Hello" can’t be coerced to a number, so the rule fails.
"Hello"!="500"Offtrue"Hello" can’t be coerced, so both remain strings. The strings aren’t equal.
"500"!="Hello"OntrueNo coercion occurs. Both are compared as strings, which aren’t equal.
"Hello"!="500"OntrueNo coercion occurs. Both are compared as strings, which aren’t equal.

Enable strict types when you need predictable string comparisons without automatic type conversion.

Construct an evaluation

Evaluations are expressions consisting of two operands (A and B) and a comparison operator. When the task runs, it compares operand A to operand B and yields true or false.

By default, evaluations display vertically. To display them horizontally, click Expand at the top-right of the task configuration window.

Evaluation groups

All evaluations belong to an evaluation group. Each group resolves to true or false by logically combining its evaluation results. Each group has its own conditional statement that works the same way as the task condition.

Create an evaluation

1

Create an evaluation group

Click + Add Evaluation Group to create a new group if one does not exist.

2

Add an evaluation

Click + Add Evaluation in the desired group.

3

Define operand A

Define operand A using one of these sources:

  • Static — Specify a data type and value.
  • Job variable — Select the variable from the dropdown menu.
  • Previous task — Select the task and its relevant variable from the dropdown menu.
4

Select the comparison operator

Select the comparison operator from the Operator dropdown menu.

5

Define operand B

Define operand B using the same source options as operand A.

Use queries with arrays and objects

If operand A is an array or object, you can use a query to determine its value:

  1. Select the Enable Query checkbox.
  2. Enter your query using the same syntax as the query task.

At runtime, the query executes and its results become the value of operand A.

Operator reference

Operator behavior depends on the data types of the operands.

Contains

Operand A typeOperand B typeBehavior
stringstringReturns true if B is a substring of A. Supports JavaScript RegExp patterns. Template variables are not supported for operand B; operand B cannot be a string of numbers.
booleanbooleanReturns true if A equals B.
numbernumberReturns true if A divided by B has no remainder.
arraystring, boolean, or numberReturns true if B is an element of A.
arrayobject or arrayAlways returns false.
objectstringWith query: Returns true if the query matches a property name in A and B is a substring of that property. Without query: Returns true if B is a substring of any property in A.
objectnumber, object, or arrayWith query: Returns true if the query matches a property name in A and B is contained by that property.

Does not contain

Operand A typeOperand B typeBehavior
stringstringReturns true if B is not a substring of A.
booleanbooleanReturns true if A doesn’t equal B.
numbernumberReturns true if A divided by B has a remainder.
arraystring, boolean, or numberReturns true if B is not an element of A.
arrayobject or arrayAlways returns false.
objectstringWith query: Returns true if the query doesn’t match a property name in A, or B isn’t a substring of that property. Without query: Returns true if B isn’t a substring of any property in A.
objectnumber, object, or arrayWith query: Returns true if the query doesn’t match a property name in A, or B isn’t contained by that property.

Greater than (>)

Operand A typeOperand B typeBehavior
stringstringCompares using lexicographical ordering.
booleanbooleantrue is greater than false.
numbernumberReturns true if A is greater than B.
arraynumberReturns true if B is less than A’s length.
arrayarrayReturns true if A’s length is greater than B’s length.
objectanyAlways returns false.

Less than (<)

Operand A typeOperand B typeBehavior
stringstringCompares using lexicographical ordering.
booleanbooleantrue is greater than false.
numbernumberReturns true if A is less than B.
arraynumberReturns true if B is greater than A’s length.
arrayarrayReturns true if A’s length is less than B’s length.
objectanyAlways returns false.

Equals (==)

Operand A typeOperand B typeBehavior
stringstringReturns true if A equals B.
booleanbooleanReturns true if A equals B.
numbernumberReturns true if A equals B.
arraynumberReturns true if B equals A’s length.
arrayarrayReturns true if A and B have the same length.
objectobjectReturns true if A and B have the same properties and values.

Does not equal (!=)

Operand A typeOperand B typeBehavior
stringstringReturns true if A doesn’t equal B.
booleanbooleanReturns true if A doesn’t equal B.
numbernumberReturns true if A doesn’t equal B.
arraynumberReturns true if B doesn’t equal A’s length.
arrayarrayReturns true if A and B have different lengths.
objectobjectReturns true if A and B have different properties or values.

Greater than or equal to (>=)

Operand A typeOperand B typeBehavior
stringstringCompares using lexicographical ordering.
booleanbooleantrue is greater than false.
numbernumberReturns true if A is greater than or equal to B.
arraynumberReturns true if B is less than or equal to A’s length.
arrayarrayReturns true if A’s length is greater than or equal to B’s length.
objectobjectAlways returns false.

Less than or equal to (<=)

Operand A typeOperand B typeBehavior
stringstringCompares using lexicographical ordering.
booleanbooleantrue is greater than false.
numbernumberReturns true if A is less than or equal to B.
arraynumberReturns true if B is greater than or equal to A’s length.
arrayarrayReturns true if A’s length is less than or equal to B’s length.
objectobjectAlways returns false.

Examples

String comparisons with contains

Operand AOperatorOperand BResult
"er1.atl"contains"atl"true
"er1.atl"contains"ATL"false

Array comparisons with contains

Operand AOperatorOperand BResult
["cr1.atl", "er1.atl"]contains"er1.atl"true
["cr1.atl", "er1.atl"]contains"atl"false

Object comparisons with contains

Operand AOperatorOperand BResult
{"name": "apple", "color": "red"}contains"color"true
{"name": "apple", "color": "red"}contains"apple"false

Regular expression patterns

Operand AOperatorOperand BResult
a1111zcontainsa[\d][\d][\d][\d]ztrue
a1111zcontainsa[\D][\D][\D][\D]zfalse
a1111zcontainsa[\d]+ztrue
white spacecontains[\s]true

Numeric comparisons

Operand AOperatorOperand BResult
4>2true
1>2false
6<9true
6==6true
6=="6"true
6!=7true
4>=4true
6<=9true

Boolean comparisons

Operand AOperatorOperand BResult
true>falsetrue
false<truetrue
false==falsetrue
false=="FALSE"true
true!=falsetrue

Array length comparisons

Operand AOperatorOperand BResult
["cr1.atl", "er1.atl"]>1true
["cr1.atl", "er1.atl"]>["cr2.atl"]true
["cr1.atl", "er1.atl"]<3true
["cr1.atl", "er1.atl"]==["cr1.atl", "er1.atl"]true

Object comparisons

Operand AOperatorOperand BResult
{"name": "cr1.atl", "ned": "cisco-ios-xr", "slots": 8}=={"name": "cr1.atl", "ned": "cisco-ios-xr", "slots": 8}true
{"name": "cr1.atl", "ned": "cisco-ios-xr", "slots": 8}=={"name": "cr1.atl", "ned": "cisco-ios-xr", "slots": "8"}false
{"name": "cr1.atl", "ned": "cisco-ios-xr", "slots": 8}!={"name": "cr2.atl", "ned": "cisco-ios-xr", "slots": 8}true

Error cases

Operand AOperatorOperand BResult
"chassis">"card"error
"card"<"chassis"error
"chassis">="card"error
"card"<="chassis"error