Automation
Guard rules
A guard rule blocks a change outright based on the record's state or the user's role. Learn how to lock approved records and allow exceptions.
Esta página aún no se ha traducido. Estás leyendo el original.
A guard refuses a change when its conditions hold. The person sees one clear message and nothing is saved. Use a guard when the change itself isn't allowed, whatever the values are: editing an approved order, deleting a posted invoice, changing a price after shipping.
A guard runs last, after computations and validations, so it sees the final values of the record.
Create a guard#
- Open any view on the table, click Settings, choose Business Rules, and click New rule.
- Enter a Name, such as "Approved orders are locked", and set the Rule type to Guard.
- Under Runs on, choose the operations to block, for example Update and Delete.
- Under When, add the conditions that make the change forbidden, for example "Status is Approved". Use Field with Before to test the value the record had before this change.
- Enter the Message shown to the user, such as "This order is approved and can no longer be changed."
- Optionally choose Fields that stay editable and Groups that can bypass.
- Click Create rule.
Fields that stay editable#
A locked record often still needs a few fields to change, such as internal notes or a tracking number. Add them under Fields that stay editable. An update that only touches those fields passes the guard.
Groups that can bypass#
Add groups under Groups that can bypass to let their members make the change anyway, for example a "Finance managers" group that can correct posted invoices. Organization owners can always bypass a guard. If the list is empty, nobody else can.
Examples#
| Guard | Runs on | When | Exceptions |
|---|---|---|---|
| Approved orders are locked | Update, Delete | Status (Before) is Approved | Notes stays editable |
| Posted invoices can't be deleted | Delete | Posted is true | Finance managers can bypass |
| Only managers can close deals | Update | Status changed to Won, and the user isn't in Sales managers | None |
Status transitions#
A Status column can already limit which moves are allowed between states. You don't need a guard for that. Add a guard when you also need a custom message or an exception for certain groups.
Debates sobre esta página
¿Te has atascado o echas algo en falta? Pregunta a la comunidad.