Compare to (Validator)

The 'Compare to' validator compares the value of the current element with the value of another field or an expression (fixed value or calculation, see Calculation field). Please refer to the documentation for the behaviour Compare with (Form designer) for configuration details and examples.

►NOTE◄ If a 'Compare to' validator for field 'A' compares its value to that of field B – with a condition 'A < B' – this validator only responds to events of field 'A' and not field 'B'. Changing the value of field 'B' does not trigger a re-validation of rule defined for field 'A', so the validation state indicated for field 'A' may be incorrect, until field 'A' is evaluated again for some other reason (e.g. before saving a business object). Immediate re-validation in response to updates of the field referred to as 'Compare source' can be achieved by explicitly triggering a Validate element behaviour from the far side of the (in-)equation, as demonstrated in the following example.

Configuration example

A specific upper limit for the unit weight per item (PRIORITY: max. 75 kg, STANDARD: max. 120 kg) should apply to a transport order depending on the selection for the Service category feature (with the PRIORITY and STANDARD options). Within a portal for transfer order definition, the applicable limit value is kept in a read-only field Max. unit weight (kg), which is (re-)set on any change of Service category.

When line items are added, an indication of Unit weight (kg) is required. A validator for the respective input field shall indicate a message '► Overweight ◄', if the weight indicated for a line item exceed the applicable limit:

images/download/attachments/36573528/image2019-6-4_11-47-28-version-1-modificationdate-1559641650000-api-v2.png

  • The 'Compare to' validator defined for the Unit weight (kg) input field inside a Repeatable element refers to Field # 12, which holds the value for Max. unit weight (kg) automatically updated upon change for the option Service category.

  • The Info text '► Overweight ◄' is presented, if Unit weight (kg) of a line item is NOT Less or equal then the limit.

Intermediate result:

images/download/attachments/36573528/image2019-6-4_11-52-10-version-1-modificationdate-1559641933000-api-v2.png

  • One of the given set of line items is rated '► Overweight ◄' for a PRIORITY transfer order.

The user should be allowed to change the selection for service category while registering line items. In this case, without the following precautions the unit weight of already registered line items would not be re-validated against the changed maximum value.

A behaviour is added to the input element for Max. unit weight (kg), which responds to the Triggering event Geändert and calls Validate element for all line items:

images/download/attachments/36573528/image2019-6-4_11-59-49-version-1-modificationdate-1559642391000-api-v2.png

  • The Validate element behaviour is linked to the Repeatable element resembling the line items.

  • Since the validation of the line items is the only purpose of the behaviour, no other actions are defined.

After switching the Service category from PRIORITY to STANDARD, the transfer order (see above) immediately appears without 'objections' regarding unit weight validation:

images/download/attachments/36573528/image2019-6-4_11-58-32-version-1-modificationdate-1559642314000-api-v2.png