# Set criteria

> Set IS Tools rule trigger criteria using field conditions (Absolute, Other field, Keyword) or record keywords like CREATED or UPDATED. Combine with AND/OR.

Criteria are conditions that must be met in order to perform an action. Similar to the statement "_if this happens…​_", the criteria usually consist of a logical expression, an equality or inequality logical operator (e.g. =, ≠, >), and a logical state or constant value (e.g., TRUE, TODAY, MISSING, or 42). For instance, the following criteria If A>=10 AND A⇐20 express the condition of having a record where the field "A" has a value between 10 and 20.

## To add criteria

1.  Select the field on which you want to set the criteria to trigger the rule. Rules can be triggered on all field types, except for Link.

2.  Choose the **Filter type**, i.e. what kind of comparison you want to make on the selected field:

    1.  The **Absolute value** trigger condition verifies the value of the selected field for equality of inequality with an absolute value. The rule is triggered if the logical expression of the trigger condition evaluates to _True_.

    2.  The **Compare two fields** trigger condition compares the value of the selected field with the value of another field. The operator, choice of other field and additional settings depend on the type of the selected field.

    3.  The **Field keyword** trigger condition allows a choice among a number of keywords describing the status of the field value:

        -   **MISSING**, no value has been entered.

        -   **CHANGED**, the field value has been modified in some way, i.e., it has been inserted or updated, or deleted.

        -   **INSERTED**, a non-empty value is saved for the first time.

        -   **UPDATED**, an existing, non-empty value has been changed.

        -   **DELETED**, the field value has been removed (i.e., a new empty value is being stored). See a [remark](#remark) about keywords.

    4.  The **Record keyword** trigger condition differs from the preceding one in that it is applied to the current record, rather than to one of its fields. As a consequence, the list of fields is not available once this condition is selected. The alternative values are:

        -   **CREATED**, a record has been created.

        -   **UPDATED**, one or more fields of a record _being created_ or an existing record have been inserted or changed value.

            > **Caution:**
            > 
            > The **UPDATED** criteria should be used with the utmost caution, because the broad scope of these types of trigger may lead to a very frequent execution of the rule, and therefore may significantly impact the system’s performance.

        -   **DELETED**, the current record is being deleted.

            > **Note:**
            > 
            > The **DELETED** condition might be good to use for example to trigger an action on a related record (e.g., after a child record is deleted, recalculate the number of my existing child records and place the result on a field of the parent record) or to send a mail, but it cannot set a value on the triggered record that is about to be deleted, i.e., cannot set a value on itself upon deletion.

        -   **UPDATE\_ONLY**, one or more fields of an _existing_ record have changed value.

            > **Caution:**
            > 
            > The **UPDATE\_ONLY** criteria should be used with the utmost caution, because the broad scope of these types of trigger may lead to a very frequent execution of the rule, and therefore may significantly impact the system’s performance.

        -   **NAME\_CHANGED**, the current record has updated its name.

3.  Set the logical state or the constant value (depending on which **Filter type** you chose for the selected field).

4.  Optionally, keep the **Only trigger once** box checked in order to prevent rules from being triggered multiple times after a first time has occurred on the same record upon Save action. This is useful in case the rule turns out to be [recursive](examples_of_rules.md#recursive). Note that this setting cannot be combined with [Scheduled rules](rule_groups.md).

5.  Then click on the **Add criteria** button.

6.  Add more criteria if necessary (repeating the previous steps), since multiple conditions can be combined by using the operators **AND** and **OR**, which indicate logical-and and logical-or, respectively. The **AND** operator has the precedence over the **OR** operator, and is executed first. In the box that displays the trigger condition being assembled (in the lower portion of the form), this is expressed by lines beginning with an **OR** operator being indented.

> **Note:**
> 
> It is important to note that the criteria will only be evaluated if there are changes in the fields included (or changes in the record in question, in case **Record keyword** is chosen). In other words, a rule will not be considered unless _at least one of the items (field/record) in the criteria is used_ when creating or saving a record on [application forms](application_forms.md), or editing via [imports](import_templates.md).
> 
> This is, in order to perform the [rule action](set_actions.md), the criteria need to be evaluated first and return True (i.e., fulfill the required value or state).
> 
> To better understand this, see [examples of criteria](#_examples_of_criteria__how_they_evaluate). See also complete [examples of rules](examples_of_rules.md).

Once the criteria is set, click on the **Next** button to continue with the [**Set actions**](set_actions.md) window.

## To remove criteria

To remove a criterion, select it in the list and click the **Remove** button. If the first line is removed in this way, also the **AND** or **OR** operator that begins the following line is removed.

> **Note:**
> 
> Criteria that is already added cannot be edited, unless they are first removed and then added again. New criteria can only be added at the bottom of the list.

To remove all the entered conditions, click the **Remove all button**.

Once the criteria is set, click on the **Next** button to continue with the [**Set actions**](set_actions.md) window.

## Examples of criteria - How they evaluate

Criteria will only be evaluated if at least one of the items (field/record) in the criteria is changed when creating or saving a record on application forms or imports. Evaluating to _True_ will trigger the rule action.

| Criteria in | Change in application form/ | Will criteria be evaluated? | Will action be triggered | Summary |
| --- | --- | --- | --- | --- |
| MyNumber = 10 | MyNumber is updated from 2 (original value) to 10, then the form is saved. | **Yes** (the field has changed value). | **Yes** (criterion returns _True_, i.e., fulfills the value needed to trigger the action). | Criterion is evaluated. Returns _True_. Action is triggered. |
| MyNumber = 10 | MyNumber remains as 10. MyText is updated. The form is saved. | **No** (the field has not changed value). | \- | Criterion is not evaluated, therefore the rule does not proceed. |
| MyNumber = 10 AND MyText = CHANGED | MyNumber remains as 10. MyText is updated. The form is saved. | **Yes** (one of the fields has changed). | **Yes** (both conditions return _True_, i.e., fulfills the value/state needed to trigger the action). | Criteria is evaluated. Returns _True_. Action is triggered. |
| MyNumber = 10 AND MyText = CHANGED | MyNumber is updated to 20. MyText is updated. The form is saved. | **Yes** (the fields have changed). | **No** (the AND operator used in criteria requires that both conditions return _True_, but only one of them did). | Criteria is evaluated. Returns _False_. Action is not triggered. |
| MyNumber = 10 OR MyText = CHANGED | MyNumber is updated to 30. MyText is updated. The form is saved. | **Yes** (the fields have changed). | **Yes** (the OR operator used in criteria requires that at least one of the conditions returns _True_, which is fulfilled). | Criteria is evaluated. Returns _True_. Action is triggered. |
| MyNumber = 30 AND Record = CHANGED | MyNumber remains as 30. MyNote is entered. The form is saved. | **Yes** (one of the items in the criteria has changed: the record, due to a modification made on one of its fields) | **Yes** (both conditions return _True_, i.e., fulfills the value/state needed to trigger the action). | Criteria is evaluated. Returns _True_. Action is triggered. |
| MyNumber = MISSING | A new record is imported. MyNumber field is empty. | **No** (the field has not changed, i.e., removed value when using this keyword). | \- | Criterion is not evaluated, therefore the rule does not proceed. |
| MyNumber = MISSING AND Record = CREATED | A new record is imported. MyNumber field is empty. | **Yes** (one of the items in the criteria has changed: the record, through its creation). | **Yes** (both conditions return _True_, i.e., fulfills the value/state needed to trigger the action). | Criteria is evaluated. Returns _True_. Action is triggered. |

Note that the comparison ≠ _CHANGED_, need to be configured together with another criterion that is changed in order to be evaluated. For instance, _FieldA ≠ CHANGED AND FieldB = UPDATED._
