Table of Contents

Conditional Rules

Lesley Updated by Lesley

What are Conditional Rules?

Conditional rules can be used to automatically set the value of a field based on the rules, or conditions, that you define for the field.

Here are some examples of how conditional rules could be used:

  • 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.
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 this field.

Manage 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:

Once you check the ‘Add Conditional Rules’ checkbox, you will see the option to add one or more rules to your field:

The rules in the image above set the Budget amount to a custom (specific) value based if the Company value for that record is ‘Regex Solutions’. If not, a default value is set with the second rule (with no criteria).

You can also compare fields to other fields by clicking on the small drop-down arrow to on the rule’s far-right side:

Once added, a "conditional" icon is displayed with the field for easy identification:

Edit Conditional Rules

You can make changes to your conditional rule directly in the editor. Just select the part of your rule that you would like to change:

Copy/Move Conditional Rules

To copy a conditional rule, click on the ‘copy’ icon in the top-right corner of the rule as shown here: 

To move and reorder your conditional rules, click on the move icon in the upper-left corner of the rule and drag the rule above or below any other rules listed for that field:

The rules run in order with the first match in criteria found. Once a match is found no other rules are checked. This is why the default always goes at the bottom.

Delete Conditional Rules

To remove a single rule, click on the trashcan icon on the top-right side of the rule:

If you would like to remove all of the conditional rules for a field, either delete each rule 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 Builder. Otherwise, you may get inconsistent results. Remember that you can move fields around in the builder by clicking and dragging them.

Also, if your equation field depends on other formulas or fields with conditional rules, you must list it after these fields since Knack processes those in order that they’re listed in the table. Another way to say this is that if an equation depends on a field, field with a conditional rule, or another equation, those fields must be listed above the equation that uses it.

Notes & Troubleshooting

  • Once a field is set to use conditional values it can no longer be added to a form or edited in inline mode. The values will only be set by the rules.
  • If a field was added to a form before conditional rules were added to the field, the value of the field will still be set by the conditional rule regardless of what is submitted.
  • You can add a field with conditional rules to your form's record rules, however, the value of the field will always be set by the conditional rule.
  • You can add multiple criteria to the "When" conditions. Every rule must be true in order to match.
  • 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 "reset" when the criteria that set the value are no longer true. You must have an opposite rule to set the value to its new state.

How did we do?


Text Formulas