How to validate a Field only WHEN a Condition is met?

Why some Validations need not run every time a record is saved.

In some instances, a validation does not need to be fired every time a record is saved, but only if a particular condition is true.

For example:

  • Validate that a Parent Action is selected,
    but only when the user ticked "Is there a Parent Action?"
  • Validate that the Name of the Offender is entered,
    but only when an Offender is not an employee.
  • Validate that the Due Date of an Action cannot be more than 30 days in the future,
    but only when the Action Priority is Urgent or High.

How do I define a Condition which evaluates whether a Validation shall be triggered?

Once you have identified a validation which only needs to be triggered under certain conditions, you can add a condition by clicking on:

Add conditions that have to be met to trigger this validation.

Then follow these steps

  1. Select the Form Field which you are using to evaluate if a validation needs to be triggered.

    Menu path separator The System will display all fields in the current form, ordered by

    • Pages, in the order as defined in the Form Builder
    • and within each Page alphabetically.

    If you need to select a value from a relationship (drill down), please see below for details.

  2. For "as-you-type" validations to work, the field selected for the WHEN condition must not be marked as 'Read-only'. Having said this, the validation will be evaluated when saving the record.
  3. Define which Condition the Field needs to meet, so that the validation is being triggered.

    Menu path separator The options which are displayed by the system will depend on the field type you selected in the previous step.

What you are able to validate against will depend on the Field Type you have selected.
Following is a collection of the possible validations, based on the Field Types of the validated field.

Field Type: ALL

Available Operators

Available Values

  • is set Menu path separator i.e. has a value
  • is not set Menu path separator i.e. does not have a value

N/A.

In addition to the above, other field types offer the following options

Field Type: Date

Available Operators

Available Values

  • [=] is equal to
  • [?] is not equal to
  • [<] is before
  • [<=] is on or before
  • [>] is after
  • [>=] is on or after

To compare the validated field against:

  • the current date, select TODAY
  • another date field on the form, select from the list of other date fields which are available on the form.

You can also add or deduct a number of days from the selected value. Click on the arrow "Menu path separator" next to the field, which then will open a control where you can set the required value.

For example:

  • Validate that Action Progress has records
    WHEN is Date Action Raised is on or before TODAY - 30 days.

Field Type: Time

Available Operators

Available Values

  • [=] is equal to
  • [?] is not equal to
  • [<] is before
  • [<=] is on or before
  • [>] is after
  • [>=] is on or after

To compare the validated field against:

  • the current system time, select NOW
  • another time field on the form, select from the list of other time fields which are available on the form.

    For example:
    Time Incident Reported is before NOW

Field Type: Lookup (single selection)

Available Operators

Available Values

  • [=] is equal to
  • [?] is not equal to

You can compare against any of the available values of the validated lookup.

To compare

  • select the value from the list of values.

    For example:
    Action Priority is equal to Urgent

Field Type: Lookup (multiple selection)

Available Operators

Available Values

  • has value
  • does not have value
  • (has ONLY value) *
  • (is single select if value is)*

 

NOTE:

while you can select all of the above operators, in the context of evaluating IF a validation needs to be triggered those marked with * cannot be used.

You can compare against any of the available values of the validated lookup.

To achieve that

  • a certain value needs to be included, select has value
  • a certain value must not be included, select does not have value
  • that only this particular value can be selected, and no other value, select has ONLY value.
  • a user can select any combination of values, EXCEPT when this particular value is included. Once this particular value has been selected, the system will behave like a single lookup, and no other values can be selected.

    For example:
    Incident Consequences has value Injury

Field Type: Number (Integer or Decimal)

Available Operators

Available Values

  • [=] is equal to
  • [?] is not equal to
  • [<] is less than
  • [>] is greater than
  • [<=] is less than or equal to
  • [>=] is greater than or equal to

To compare the validated field against:

  • a fixed value, select a Constant from the list.
    Note that only if a constant has been defined, will you be able to select one from the list.
  • another number field on the form, select from the list of other number fields which are available on the form.

    For example:
    Max Measurement is less than Min Measurement.

Field Type: Subforms

Available Operators

Available Values

  • Has Records
  • Has No Records

N/A

How can I "drill down" for the WHEN condition?

In some instances, it may be necessary to evaluate the WHEN condition from a field which is not on the current form, but is stored in one of the related records.

For example consider an Incident Form with the validation:

  • Validate that the field 'Has the Contractor been notified' has been ticked if the Employment Status of the Injured Person is 'External'.

While you will have a field "Injured Person" on the form, the information of the Employment Status is contained on the related Person record.

Question

Answer

How can I identify if it is possible to drill down on a field?

If you select a field/relationship which offers drill down, the system will display a Menu path separator symbol next to the field name.

How do I drill down?

Simply by clicking on the Menu path separator symbol.

The system will display lookups and 'next-level' relationships of the selected relationship, from which you can select the required field.

To define the condition, proceed as described above.

Why can't I drill down to all relationships?

Due to technical limitations, it is not possible to drill down to 'To-Many' relationships.

What if I need Multiple Conditions?

It is possible to combine several conditions.

Examples:

  • Validate that the field 'Incident Close Off Date' has a value, when

    'Can Incident be closed = Yes'
    AND
    'Incident Signed Off by' has a value

  • Validate that the Action Due Date is within 30 days of Today, when

    'Action Priority = HIGH'
    OR
    'Action Priority = URGENT'

Question

Answer

How can add additional conditions?

Click on the green '+' icon next to the existing condition

How can I toggle between AND and OR?

Clicking on AND or OR will toggle between these two values.

Note: if you have more that two conditions, clicking on any AND/OR will change this operator for ALL conditions.

Can I mix AND and OR within a WHEN condition?

No, this isn't possible. ALL conditions are either combined by AND, or by OR.

Hint

For the sake of clear error messages for the End User, the OR operator should only be used sparingly for the WHEN condition.

We recommend to use individual validations instead, which will allow the designer to write a clear and precise Validation Message, rather than having to state "try this, OR try that".

See Also

Validations

How to define Validations

Creating a New Validation

Perform a Validation across several Pages

Filtering and Finding Validations in the Validation Designer

Sample Validations