Help Center Tables and records
Save rules
Stop a record from being saved when it breaks a rule you set, such as picking more than is in stock, and compare one column with another.
A save rule refuses to save a record that matches conditions you set, and shows your message instead. Use one when a record must never be saved in a certain state: a pick larger than the stock on hand, an expiry date before the date made, a deviation closed while actions are still open. Managers set rules for the whole table, and they apply to everyone.
How a save rule works
A rule has a name, a message and one or more conditions. When a record matches the conditions, the save is refused, nothing is kept, and the person sees your message. This is different from Required, which only asks for a value. With a save rule, no value or reason lets the record through while it matches.
A rule is checked:
- when a record is added, including from a template;
- when a record is edited;
- when a signer fills in their columns during a review;
- when records are imported (the whole import is refused if one record breaks a rule).
Changes an automation makes to other records are checked against that table's rules too: adding to or subtracting from a linked record, setting a linked column, and creating a record. If one breaks a rule, the whole change is refused, including the record that started it, and the message names the automation. For example, a rule on a stock table that stops On hand going below 0 stops a pick that would take it negative. The record that triggers an automation is checked when it is saved, not again afterwards.
Rules are checked after the record's values are written and before any automation runs. So a rule sees the other records as they were before this change. For example, a pick is checked against the stock before an automation takes the picked amount off the stock.
Add a save rule
- Open the table and click View settings, then Save rules (managers). A number beside it shows how many rules the table has.
- Click + Add a rule.
- Enter a Rule name, for example "No over-pick".
- Enter the Message people see when it stops a save, for example "Only what is in stock can be picked". Say what is wrong in words the person can act on.
- Click + Add filter and build the condition the same way as a view's filter. The save is refused when the record matches it, so write the condition for the bad case, for example "Quantity is more than In stock".
- With more than one condition, choose whether the record must match all conditions or any condition for the save to be stopped.
- Click Save rules.
Remove a rule with its trash button. A rule with no name, no message or an incomplete condition can't be saved.
Compare one column with another
For a number or date column, the condition has a choice after the operator: a value, or the column followed by another column's name. Choose the column to compare two columns of the same record, for example:
| Condition | Stops the save when |
|---|---|
| Quantity is more than the column In stock | A pick is larger than the stock |
| Expires is before the column Made | A lot expires before it was made |
| Due date is before the column Opened | A due date is earlier than the opening date |
Both columns must be the same kind: two number columns (numbers, percentages, currency, or a formula or rollup that gives a number) or two date columns. If the column you compare with is empty, the condition doesn't match, so the record isn't stopped.
A condition can also compare with a column of a linked record. Choose a column of a linked record, then the link column of this table (for example the Sample) and its column (for example Location):
| Condition | Stops the save when |
|---|---|
| From location is not the same as the Sample's Location | A movement takes a sample from a place it isn't in |
| Quantity is more than the Sample's Available | A pick is larger than the sample's stock, without needing a rollup |
For a link column there are two more conditions, is the same as and is not the same as. They compare it with another link column of the record, or with a link column of a linked record, and both must link to the same table. A number can be compared with a number column of a linked record: a stored number, not a calculated one.
Only save rules can compare a column with another column. Saved views, automation conditions and Required when use typed values.
Use calculated columns
A rule can use formula and rollup columns. That is how to compare a record with a linked record: add a Rollup that sums or takes the maximum of a number on the linked record (see Link tables and calculate), then compare your column with it. A lookup column can't be used, because lookups can't be filtered.
Note: A rollup shows the linked record's number as it is when the record is saved. If an automation changes that number when the record is created, the rule still sees the number from before, which is what you want for a stock check.
When a save is refused
The form stays open with your message, and nothing is saved. In an import, no records are added. The person fixes the value and saves again. Adding, changing or removing rules needs the Manage level, and every change is in the table's audit trail. When the table's setup is locked, the rules can't be changed.