evaluation
  • 06 Oct 2023
  • Dark
    Light
  • PDF

evaluation

  • Dark
    Light
  • PDF

Article summary

Task Purpose

The evaluation task controls the job execution path according to runtime conditions.

Figure 1: Evaluation Task

Evaluation Task

If the condition specified in the task is met, the task outputs the value true. Execution then continues down any success transitions bound to the task.

Figure 2: Evaluation Task Output Success

Evaluation Task Output Success

Otherwise, the task outputs the value undefined and execution continues down any failure transitions bound to the task.

Figure 3: Evaluation Task Output Failure

Evaluation Task Output Failure

In this guide, you will learn:

  • How to set the condition of the evaluation task.
  • How to construct the expressions (evaluations) used to determine if that condition has been met.
  • The properties that can be used in these evaluations.

Condition

First, set the task condition. The condition is an "if" statement, reading as follows:

"If <any | all> of the following are met:"

When the condition is completed with any, the task will output the value true if any of its evaluation groups resolve as true. Likewise, if the condition is completed with all, the task will only output the value true if all of its evaluation groups resolve as true.

To set the condition:

  1. Click the dropdown arrow in the condition statement located at the top of the task configuration window.
  2. Select an option from the menu that appears.

Evaluations

After the task's condition has been set, you can begin constructing the evaluations that will be compared against it. Evaluations are expressions that consist of two operands (A and B) and a comparison operator. When the task executes, operand A is compared to operand B, yielding a result of true or false.

ⓘ Note:

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

All evaluations are members of an evaluation group, which resolves to true or false by logically combining its evaluation results. Each evaluation group has its own conditional statement -- this operates in the same manner as the task condition.

To construct an evaluation:

  1. If one does not already exist, create an evaluation group by clicking the + Add Evaluation Group button.
  2. Click the + Add Evaluation button in the desired evaluation group.
  3. Define operand A:
    • If its source is static, a data type and value must be defined.
    • If its source is a job variable, select the desired job variable from the dropdown menu that appears.
    • If its source is a previous task, select the desired task and its relevant variable from the dropdown menu that appears.
  4. Select the operator that will be used to compare the operands via the Operator dropdown menu.
  5. Define operand B.
ⓘ Note:

If operand A is an array or object, its value can be determined via a query by selecting the Enable Query check box. At runtime, the query will be executed and its results will be used as the value of operand A. Queries use the same syntax as the query task; refer to its documentation for more information.

Evaluation Properties - Operators

The behavior of each operator is dependent on the data type(s) of its operands; for more information, see the tables below.

Contains

Operand A Data Type Operator Operand B Data Type Comparison
string contains string Returns true if operand B is a substring of operand A. String patterns from the JavaScript RegExp Library are also supported, with the following caveats:

- The operands must have a source of Static.
- Template variables are not supported for operand B.
- Operand B may not be a string of numbers.
boolean contains boolean Performs an equality test (returns true if operand A equals operand B).
number contains number Divides operand A by operand B. If there is no remainder, the evaluation resolves as true; otherwise, it resolves as false.
array contains string, boolean, or number Returns true if operand B is an element of operand A.
array contains object or array Always returns false.
object contains string When using a query parameter, returns true if both of the following criteria are met:

- The query value matches the name of a property in operand A.
- Operand B is a substring of that property.

When not using a query parameter, returns true if operand B is a substring of any property in operand A.
object contains number, object, or array When using a query parameter, returns true if both of the following criteria are met:

- The query value matches the name of a property in operand A.
- Operand B is contained by that property.

Does not contain

Operand A Data Type Operator Operand B Data Type Comparison
string !contains string Returns true if operand B is not a substring of operand A.
boolean !contains boolean Performs an inequality test (returns true if operand A does not equal operand B).
number !contains number Divides operand A by operand B. If there is a remainder, the evaluation resolves as true; otherwise, it resolves as false.
array !contains string, boolean, or number Returns true if operand B is not an element of operand A.
array !contains object or array Always returns false.
object !contains string When using a query parameter, returns true if at least one of the following criteria are met:

- The query value does not match the name of a property in operand A.
- Operand B is not a substring of that property.

When not using a query parameter, returns true if operand B is not a substring of any property in operand A.
object !contains number, object, or array When using a query parameter, returns true if at least one of the following criteria are met:

- The query value does not match the name of a property in operand A.
- Operand B is not contained by that property.

Greater than

Operand A Data Type Operator Operand B Data Type Comparison
string > string Performs evaluations based on lexicographical ordering; refer to Wikipedia - Lexicographical Order for more information.
boolean > boolean True is greater than false.
number > number Returns true if operand A is greater than operand B.
array > number Returns true if operand B is less than the length of operand A.
array > array Returns true if the length of operand A is greater than the length of operand B.
object > any data type Always returns false.

Less than

Operand A Data Type Operator Operand B Data Type Comparison
string < string Performs evaluations based on lexicographical ordering; refer to Wikipedia - Lexicographical Order for more information.
boolean < boolean True is greater than false.
number < number Returns true if operand A is less than operand B.
array < number Returns true if operand B is greater than the length of operand A.
array < array Returns true if the length of operand A is less than the length of operand B.
object < any data type Always returns false.

Equals

Operand A Data Type Operator Operand B Data Type Comparison
string == string Returns true if operand A is equal to operand B.
boolean == boolean Returns true if operand A is equal to operand B.
number == number Returns true if operand A is equal to operand B.
array == number Returns true if operand B is equal to the length of operand A.
array == array Returns true if operand A and B are the same length.
object == object Returns true if operand A and B contain the same properties and values.

Does not equal

Operand A Data Type Operator Operand B Data Type Comparison
string != string Returns true if operand A is not equal to operand B.
boolean != boolean Returns true if operand A is not equal to operand B.
number != number Returns true if operand A is not equal to operand B.
array != number Returns true if operand B is not equal to the length of operand A.
array != array Returns true if operand A and B are not the same length.
object != object Returns true if operand A and B do not contain the same properties and values.

Greater than or equal to

Operand A Data Type Operator Operand B Data Type Comparison
string >= string Performs evaluations based on lexicographical ordering; refer to Wikipedia - Lexicographical Order for more information.
boolean >= boolean True is greater than false.
number >= number Returns true if operand A is greater than or equal to operand B.
array >= number Returns true if operand B is less than or equal to the length of operand A.
array >= array Returns true if the length of operand A is greater than or equal to the length of operand B.
object >= object Always returns false.

Less than or equal to

Operand A Data Type Operator Operand B Data Type Comparison
string <= string Performs evaluations based on lexicographical ordering; refer to Wikipedia - Lexicographical Order for more information.
boolean <= boolean True is greater than false.
number <= number Returns true if operand A is less than or equal to operand B.
array <= number Returns true if operand B is greater than or equal to the length of operand A.
array <= array Returns true if the length of operand A is less than or equal to the length of operand B.
object <= object Always returns false.

Example Evaluations

The following table provides sample evaluations and their results.

Operand A Operator Operand B Results
"er1.atl" contains "atl" T
"er1.atl" contains "ATL" F
[ "cr1.atl", "er1.atl" ] contains "er1.atl" T
[ "cr1.atl", "er1.atl" ] contains "atl" F
{ "name": "apple", "color": "red" } contains "color" T
{ "name": "apple", "color": "red" } contains "apple" F
a1111z contains a[\d][\d][\d][\d]z] T
a1111z contains a[\D][\D][\D][\D]z] F
a1111z contains a[\d]+z T
a1111z contains a[\D]+z F
white space contains [\s] T
white space contains ^ [\s]$ F
4 > 2 T
1 > 2 F
true > false T
true > 0 F
1 > false F
false > true F
"chassis" > "card" error
"chassis" > 4 F
"code" > "card" error
"code" > "17" F
[ "cr1.atl", "er1.atl" ] > 1 T
[ "cr1.atl", "er1.atl" ] > [ "cr2.atl" ] T
[ "cr1.atl", "er1.atl" ] > 3 F
6 < 9 T
9 < 6 F
false < true T
false < TRUE T
false < 5 F
true < false F
"card" < "chassis" error
"card" < 5 F
"code" < "card" error
[ "cr1.atl", "er1.atl" ] < 3 T
[ "cr2.atl" ] < [ "cr1.atl", "er1.atl" ] T
[ "cr1.atl", "er1.atl" ] < 1 F
6 == 6 T
6 == "6" T
6 == 7 F
false == false T
false == FALSE T
false == "FALSE" T
true == false F
"card" == "card" T
"card" == "chassis" F
"card" == "code" F
[ "cr1.atl", "er1.atl" ] == [ "cr1.atl", "er1.atl" ] T
[ "cr1.atl", "er1.atl" ] == [ "er1.atl", "cr1.atl" ] T
[ "cr1.atl", "er1.atl" ] == [ "cr1.atl", "cr2.atl" ] T
[ "cr1.atl", "er1.atl" ] == [ "cr1.atl" ] F
[ "cr1.atl", "er1.atl" ] == [ "cr1.atl", "cr1.atl", "cr1.atl" ] F
{ "name": "cr1.atl", "ned": "cisco-ios-xr", "slots" = 8 } == { "name": "cr1.atl", "ned": "cisco-ios-xr", "slots" = 8 } T
{ "name": "cr1.atl", "ned": "cisco-ios-xr", "slots" = 8 } == { "name": "cr1.atl", "ned": "cisco-ios-xr", "slots" = "8" } F
{ "name": "cr1.atl", "ned": "cisco-ios-xr", "slots" = 8 } == { "name": "cr2.atl", "ned": "cisco-ios-xr", "slots" = 8 } F
6 != 7 T
6 != 6 F
6 != "6" F
true != false T
false != false F
false != "FALSE" F
"card" != "chassis" T
"card" != "code" T
"card" != "card" F
[ "cr1.atl", "er1.atl" ] != [ "cr1.atl", "cr2.atl" ] F
[ "cr1.atl", "er1.atl" ] != [ "er1.atl", "cr1.atl" ] F
[ "cr1.atl", "er1.atl" ] != [ "cr1.atl", "er1.atl" ] F
[ "cr1.atl", "er1.atl" ] != [ "cr1.atl" ] T
[ "cr1.atl", "er1.atl" ] != [ "cr1.atl", "cr1.atl", "cr1.atl" ] T
{ "name": "cr1.atl", "ned": "cisco-ios-xr", "slots" = 8 } != { "name": "cr2.atl", "ned": "cisco-ios-xr", "slots" = 8 } T
{ "name": "cr1.atl", "ned": "cisco-ios-xr", "slots" = 8 } != { "name": "cr1.atl", "ned": "cisco-ios-xr", "slots" = 8 } F
{ "name": "cr1.atl", "ned": "cisco-ios-xr", "slots" = 8 } != { "name": "cr1.atl", "ned": "cisco-ios-xr", "slots" = "8" } T
4 >= 4 T
1 >= 2 F
true >= true T
false >= true F
"FALSE" >= true F
"chassis" >= "card" error
"code" >= "card" error
"code" >= 4 F
"card" >= "chassis" error
[ "cr1.atl", "er1.atl" ] >= 1 T
[ "cr1.atl", "er1.atl" ] >= [ "cr2.atl" ] T
[ "cr1.atl", "er1.atl" ] >= 3 F
6 <= 9 T
9 <= 6 F
false <= true T
FALSE <= "TruE" T
false <= 0 F
true <= false F
true <= "FALsE" F
"card" <= "chassis" error
"code" <= "card" error
"code" <= 3 F
"code" <= 9 F
"code" <= "3" F
[ "cr1.atl", "er1.atl" ] <= 3 T
[ "cr1.atl", "er1.atl" ] <= 1 F
[ "cr1.atl", "er1.atl" ] <= [ "cr2.atl", "cr3.atl", "cr4.atl" ] T
[ "cr1.atl", "er1.atl" ] <= [ "cr2.atl" ] F

References

For more information on using regular expression syntax:


Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.