Using Conditional Rules

This article will provide you with a understanding of conditional rules, including how to effectively manage them, the available settings, and troubleshooting tips.

This article covers the following topics:

 

What are conditional rules?

Conditional rules enable the automatic setting of field values based on the rules or conditions defined for the field. These rules can be set to fields of your choice.

Below are a few examples illustrating how conditional rules can be utilized:

  • The value of a Student Rank Field is set to "Honor Roll" if the GPA is higher than 3.

  • The value of a Commission Rate Field is set to 5% if the Years Experience is higher than 2.

  • The value of an Invoice Status Field is set to "Overdue" if Days Overdue is higher than 0.

Note: Once you add even one conditional rule to a field, records' values for that field will only be set by conditional rules; you won’t be able to manually update the value of the field, and no other updates will affect values for that field.

 

Managing Conditional Rules

Adding Conditional Rules

Conditional rules can be added in the Data section of the Builder. Select the table that contains the field you would like to add the rule to.

Then, click on the more options "..." icon next to the field’s name. Conditional rules will appear as an option in this dropdown menu.

For example, in this case, we would like to add a conditional rule to the Task Status field in the Notes table:

conditional1

After checking the "Add Conditional Rules" checkbox, you will have the option to add one or more rules to your field:

conditional2

The rules in the image above set the Task Status to "Pending" if there is no Contact assigned. If there is a contact assigned already, a default value is set with the second rule as "Completed".

You can also compare fields to other fields by clicking on the dropdown arrows seen in the image below.

Note: The option to select another field for comparison is limited to specific operators. For instance, when using the "is blank" operator as shown in the image above, you won't have the choice to select another field.

 conditonal3

There are two options under the section "Set" when editing conditional rules where you can choose how your records' values will be updated:

  1. "to a custom value": With this option, you have the ability to select a specific value that you wish to use for updating the record when the conditional rule is activated.

  2. "to a field value": By selecting this option, you can choose a field from the table. When the conditional rule is activated, the values of the selected field will be utilized for updating the values of your records.

Once a conditional rule is added to a field, an icon is displayed with the field for easy identification:

conditional4

 

Editing Conditional Rules

Feel free to make changes to your conditional rule directly in the editor. Simply select the part of your rule that you would like to modify: 

conditional5

 

Copying/Moving Conditional Rules

To make a copy of a conditional rule, simply click on the "copy" icon located in the top-right corner of the rule, as shown here: 

conditional6

To rearrange and change the order of your conditional rules, simply click on the move icon located in the upper-left corner of the rule and drag it above or below any other rules that are listed for that particular field.

conditional7

Note: The rules are processed in a sequential manner, where the first matching criteria is applied. Once a match is found, the system does not check any further rules.

It is important to note that this is why the default rule should always be placed at the bottom of the list of rules.

 

Deleting Conditional Rules

To delete a single conditional rule, simply click on the trashcan icon located on the top-right side of the rule. 

conditional8

Tip: If you would like to remove all of the conditional rules for a field, either delete each rule individually as shown above, or uncheck the "Add Conditional Rule" checkbox above your first rule.

 

Order of Operations

Any field referenced in a conditional rule must be listed above the field that contains the conditional rule in your table's field list. Otherwise, you may get inconsistent results.

Keep in mind that you have the flexibility to rearrange fields in the Builder simply by dragging and dropping them.

Also, if an equation field depends on other formulas or fields with conditional rules, you must list the equation field after the other fields since Knack processes those in order that they’re listed in the table.

Put simply, if an equation relies on a field, a field with a conditional rule, or another equation, it is essential that those fields are listed above the equation that utilizes them.

conditional9

 

Notes & Troubleshooting

  • Once a field is configured to use conditional values, it cannot be included in a form or edited inline. The values of the field will be exclusively determined by the defined rules.

  • If a field was added to a form prior to the addition of conditional rules to the field, the value of the field will be determined by the conditional rule, regardless of the information submitted.

  • You have the option to include a field with conditional rules in your form's record rules. In this case, the value of the field will be determined exclusively by the conditional rule.

  • You have the ability to add multiple criteria to the "When" conditions. However, it is important to note that for a rule to match, every criteria must be true.

  • You can add a rule at the end with zero conditions that will set a "default" value in case any of the previous rules aren't matched. For example, you have a Yes/No field with a default value of "No" and have conditional rules that set the value to "Yes".

    • You will also need to add a conditional rule that first sets all the values to "No". The other conditional rules for "Yes" can follow.

  • Values are not automatically reverted to their original state when the conditions that initially set the value are no longer true. To update the value to its new state, you need to create an opposite rule that will set the value accordingly.