About Conditional Rules
You can add rules to any field that can be used to set the value of that field based on conditions that you define.
Knack Tip: Once you add even one conditional rule to a field, records' values for that field will only be set by conditional rules; no other updates will affect values for this 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.
Adding Conditional Rules
To add conditional values to a field, click on the "gear" icon to the right side of the field:
Click on that to open up a pop-up for Field Options where conditional rules can be added after selecting their tab:
The rules in the image above set a commission rate to custom (specific) values based on the value in the Years Experience field. A default value is set with the second rule (with no criteria).
The first rule is comparing the "Years Experience" Field to a custom value (4).
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:
Notes & Troubleshooting
- 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.
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.
You can add multiple criteria to the "When" conditions. Every rule must be true in order to match.
Any field referenced in a conditional rule must be listed above the field with that 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.
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.