compareFields

A Workflow Engine function that returns true or false based on the comparison of two string or number values.

You can use this function as an action in a workflow. The JavaScript localCompare() method compares the two strings. Both the left-hand and right-hand side are converted to lower case before comparison takes place. Valid operators are: >, <, >=, <=, !=, =. The = operator translates to the JavaScript strict equality operator === and the != operator translates to the strict inequality operator !==.

If the comparison returns true, then compareFields returns true. Otherwise, compareFields returns false.

If either the left-hand side or right-hand value of the comparison is null, then compareFields returns false.

Coercion takes place when one side of the comparison is a string of digits and the other side is a number. If coercion fails, then compareFields will return false. If the value for either side is not a number or a string, then compareFields will return false.

This function is available as a feature of the Add-ons v2.1 download and later. See Install Moogsoft Add-ons for information on how to upgrade.

This function is available for alert, enrichment, and Situation workflows.

The workflow sweep up filter applies to this function.

Back to Workflow Engine Functions Reference.Workflow Engine Functions Reference

Arguments

Workflow Engine function compareFields takes the following arguments:

Name

Required

Type

Description

leftSide

Yes

String

The left-hand side of the comparison expression. A condition that can be evaluated to return a true or false value. This argument can be substituted.

operator

Yes

String

A binary comparison operator that takes two operands and returns true or false. Do not user quotes around the operator.

rightSide

Yes

String

The right-hand side of the comparison expression. A condition that can be evaluated to return a true or false value. This argument can be substituted.

Example

The following example demonstrates typical use of Workflow Engine function compareFields.

You want to increase the severity of an alert to critical if the value of custom_info.impact is greater than or equal to 1000. Create an Alert Workflow with a compareFields action and a setSeverity action. Set the following for compareFields:

  • leftSide: $TO_INT(custom_info.impact)

  • operator: >=

  • rightSide: 1000

The UI translates your settings to the following JSON:

{"leftSide":"$TO_INT(custom_info.impact)","operator":">=","rightSide":"1000"}