Rule items

Rules > Rules manager > Rule items

Rules are statements configured to automatically execute a procedure triggered by a certain condition. Basically, rules consist of two parts: criteria and actions. Criteria are conditions that must be met in order to trigger an action (e.g., a criterion can be that the numeric value of a field is within a specified range). Actions are operations to be performed on a target element (e.g., changing the value stored in a field). In other words, it’s an "If-Then" (if this happens, then do that) statement.

The rules are shown as a list in the Rules section of the Rules manager. Click on a specific group to display just its rules. The following actions can be performed on rules:

Create a rule

  1. Click on the New rule button and type a Name on the Edit section that was just displayed. Optionally, add a Description where you can explain what the rule is for.

  2. Choose a Trigger table to which the criteria of the rule will apply.

    For cases where you wish to trigger the rule without criteria, then choose No trigger, but be aware that a type of rule like this must be called by the trigger IQL function.

  3. Then choose a Target table on which the action of the rule will be executed, in case the criteria is fulfilled. Note that the options displayed here depend on the relations of the trigger table.

  4. Other settings:

    • 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. Note that this setting cannot be combined with scheduled rules.

    • The checkbox called Use old relation value to identify target record is available only if the current record has a reverse relation to another table. If ticked, the rule targets the record pointed to by the Relation before the change that triggered the rule. If the checkbox is not ticked, the rule targets the record pointed to by the Relation after the change that triggered the rule. For instance, the situation in which the old parent’s record must be changed: the table "Manager" has a reverse relation with the table "Employee", and there is the need to reassign a specific Employee from one Manager to another. Besides, the "Manager" table contains a field called "Number of employees", that counts the total Employees assigned to a Manager, which needs to be updated when the reassignation occurs. If the checkbox is ticked, the "Number of employees" will be decreased by one on the original Manager record since its Employee will not belong to it anymore; however, the "Number of employees" on the newly assigned Manager record will not be increased by one, unless a copy of this rule is made, with this checkbox unticked.

    • The Active checkbox refers that the system will evaluate the content of the item.

      Use the More actions…​ button to activate or deactivate multiple rules selected at once.

  5. Choose a Trigger condition, i.e. what kind of comparison you want to make:

    • The Absolute value option 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.

    • The Compare two fields option 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.

    • The Field keyword option 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 about keywords.

    • The Record keyword option 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 inserted or changed value. DELETED, the current record is being deleted. And UPDATE_ONLY, one or more fields of an existing record have changed value.

      A rule triggered by a CREATED condition does not, in turn, trigger other rules based on the same condition. This is a feature designed to prevent circular loops.

      The UPDATED and 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.

      The DELETED condition might be good to use, for example, to trigger an action on a related record. For example, after a child record is deleted, recalculate the number of existing child records and place the result on a field of the parent record; you may also send a mail upon deletion of a related record, but it cannot set a value on the active record upon deletion.

      Taking the first example, to trigger an action on a related record, let’s say that the Trigger table is "Invoice" with condition Record keyword = DELETED, and the Target table is "Invoice Item", and we expect that whenever an invoice is deleted, its items are no longer visible to users.

      See another example here.

  6. Add more criteria if necessary by using the buttons 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.

    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, or editing via imports.

    This is, in order to perform the rule action, 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. See also complete examples of rules.

  7. Once the criteria is set, click on the Add button below and set an action.

  8. Add more actions if necessary.

  9. Save.

Pay attention to the Warnings column of the Rules section as it may offer detailed information regarding issues encountered while running the rules.

Edit a rule

Select the desired rule and click the Edit button. Save the changes.

Delete a rule

Select the desired rule(s) and click the Delete button. Confirm deletion.

Copy a rule

Select the desired rule and click the Clone button. Do the proper changes and save after that.

Copying a rule may be useful, for instance, when several rules have to be created with the same criteria but different actions, and you want to avoid the manual creation of rules, one by one. Instead, copy, and edit a specific part of the rule.

Note that the rules will be executed in the order they are listed within the group, i.e., from top to bottom.