Compare with (Form designer)

The Behaviour type Compare with (Form designer) compares the value of a source element in a form with the value of Compare source that defines a reference to another form element or an expression (see Calculation expression) by which a value is determined or assigned as a fixed value.

images/download/attachments/189432367/image-2024-10-2_9-14-50-version-1-modificationdate-1727853290609-api-v2.png

The comparison always starts from the source element, which is determined as follows:

  • If no source element is linked, the executing element is considered the source element.

  • If a source element is linked, the linked element is considered the source element.

The other parameters, Compare type and Compare source, define a comparison condition for the source element.

  • If the value of the source element fulfills the comparison condition, the Actions on 'true' are executed.

  • If the value of the source element does not fulfill the comparison condition, the Actions on 'false' are executed.

In both cases, any input data is passed to the actions as $input and not the value of the source element or comparison source.

The choice for Compare type defines what type of condition the behaviour will return 'true'. The following types are available for comparison:

Compare type

Condition fulfilled when result is 'true'

Equal

field value is equal to the compared value (field or expression)

Unequal

field value is not equal to the compared value (field or expression)

Greater

field value is greater than the compared value (field or expression)

Greater or equal

field value is greater than or equal to the compared value (field or expression)

Less

field value is less than the compared value (field or expression)

Less or equal

field value is less than or equal to the compared value (field or expression)

images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg IMPORTANTimages/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg

Depending on the data type, the comparison relies on numeric values (numeric value, date/time) or text values (strings or element names of an enumeration, see also the example for Dynamic enumerations for behaviour Filled with). For a Text field, the choice for Restrict (input restriction) controls, whether content is interpreted as text or numbers (if possible). If one of the comparison values qualifies as a numeric value, the number values are compared, provided the other value can be converted into a numerical value. Otherwise texts are compared.

Example: (the blue background highlights rows where texts are compared instead of numbers)

Field (element type, value)

Compare type

Compare source (element type, value)

Result

Background

Text field (No restriction)
"100"

less
<

Text field (No restriction)
"99"

true
images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/check.svg

Compared text
"100" < "99"

Text field (Integer only)
100

less
<

Text field (No restriction)
"99"

false
images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/error.svg

Compared numbers
100 > 99

Text field (Integer only)
100

less
<

Text field (No restriction)
"1e3"

true
images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/check.svg

Compared numbers
100 < 1000

Text field (No restriction)
"1e2"

less
<

Text field (Integer only)
1000

true
images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/check.svg

Compared numbers
100 < 1000

Text field (No restriction)
"C"

less
<

Text field (Integer only)
1000

false
images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/error.svg

Compared text
"C"> "1000"

Text field (No restriction)
"0"

equal
=

Text field (No restriction)
"000"

false
images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/error.svg

Compared text
"0" != "00"

Text field (Integer only)
"0"

equal
=

Text field (No restriction)
"000"

true
images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/check.svg

Compared numbers
0 = 0

►NOTE◄ Comparisons of date/time values consider the timezone selected. Actually, the comparison refers to the numerical values for 'milliseconds since epoch' which are by definition linked to UTC. This value is also referred to when date/time values are compared to numerical values.

The choice for Compare source defines the origin of the value to be compared. The following options are available:

Compare source

Examples

Explanation

Field

images/download/attachments/189432367/image-2024-10-2_9-18-0-version-1-modificationdate-1727853480151-api-v2.png

The behaviour returns 'true',
if the field value is 'Equal' to the value of the linked 'Text field with ID 6'.

Expression

images/download/attachments/189432367/image-2024-10-2_9-17-9-version-1-modificationdate-1727853429815-api-v2.png

The behaviour returns 'true',
if the field value is 'Greater' than the fixed value '5' defined by the expression.

images/download/attachments/189432367/image-2024-10-2_9-19-8-version-1-modificationdate-1727853548126-api-v2.png

The behaviour returns 'true',
if the field value is 'Equal' to the value of the linked 'Text field with ID 28'.

►NOTE◄ This configuration is equivalent to the first example for the Compare source 'Field'. For a simple reference to a field, using an expression does not add value. However, many of the other functions available for Calculation field can be used in expressions to assign values to compare dynamically. Examples:

  • Compare with 'less or equal' 'Expression' MIN(FIELD(12),FIELD(14))... returns 'true' if the value of the current element does not exceed the smaller value of fields 12 and 14.

  • Compare with 'less or equal' 'Expression' MAX(ALLFIELDS(FIELD(26))... returns 'true' if the value of the current element does not exceed the maximum value of field 26 within a Repeatable element.

  • Compare with 'equal' 'Expression' RB(lobsterui,okLabel)... returns 'true', if the text value of the current element matches the localization text for 'OK' buttons (default: 'OK') according to Localization or Company specific localization.

  • Compare with 'equal' 'Expression' MIN(PARSE({$ifEmpty({28},0,{28})}),PARSE({$ifEmpty({29},0,{29})}))... returns 'true' if the value of the current element matches the lesser value of fields 28 and 29, where a value of 0 is assumed for empty fields.

Example

The following compare behaviour verifies if the value entered for the text field Password confirmation matches the original Password, and shows or hides the button to submit the password change depending on the result.

Configuration

Result

images/download/attachments/189432367/image2019-5-29_17-18-36-version-1-modificationdate-1727852639194-api-v2.png

images/download/attachments/189432367/image2019-5-29_17-21-14-version-1-modificationdate-1727852639192-api-v2.png


images/download/attachments/189432367/image2019-5-29_17-21-46-version-1-modificationdate-1727852639189-api-v2.png