Skip to content

Stop bad data with the Rule Book

How-to8 minPractitioner

Before you start

The Rule Book holds checks that run right before a record is saved. Use it for rules that involve more than one field or a calculation, such as “a contract’s value must be above zero” or “an invoice date must fall within its service period”. A rule either warns the person or stops the save.

  1. Click Form rules in the toolbar of the Form builder.
  2. Scroll to Rule Book and click Add Rule. The Rule Book Entry dialog opens.
  3. Type a Rule Code, for example CON-001.
  4. Choose a Severity: Warning (user can proceed) or Block (hard stop).
  5. Type a Rule Name, for example Contract value above zero.
  6. Type the Decision Message, the sentence people read when the rule fails.
  7. Write the Script. It must pass only when it evaluates to true.
  8. Click Save Rule, then Save in the panel and Save on the form.
The Rule Book section of the Form Settings panel, empty, with the Add Rule button at its right.
    Rule Book: “Smart script rules that run before save. Rules can block or warn the user.”
    Add Rule opens the entry dialog.
    Until you add one, the list says “No rules defined yet. Rules run before save.”

Each rule in the list shows its code, its name and its severity. A switch turns the rule on or off. The pencil edits it and the bin removes it.

Rules are written in Smart ScriptSmart ScriptBeezr's scripting language (engine name Beezl) used in fields, rules, filters, workflow values and dashboards.Open glossary ↗. The rule passes when the script evaluates to true. Anything else, including false or an empty result, fails it.

Write one expression that evaluates to true or false, without return.

parseFloat($cm_contracts$.$contract_value$) > 0

Use the full $table$.$field$ token for each field. Press Ctrl + Space in the editor for suggestions. Wrap numbers in parseFloat or parseInt before you compare or add them.

When someone saves a record in App space, Beezr first checks the required fields. Then it runs every rule that is switched on and has a script. If any rule fails, a Rule Book Check dialog opens with “The following rules require your attention before saving.”

  • Rules with Block severity are listed under Blocked. Click Close to return to the form.
  • Rules with Warning severity are listed under Warning. If there are no blocks, a Proceed Anyway button saves the record regardless.

The dialog shows each rule’s code, name and Decision Message.

  • Test every new rule with a sample record. A script that throws an error counts as a Block and shows the error text.
  • Give every rule its own Rule Code. Beezr identifies a rule by its code, with symbols replaced by underscores. Two rules with the same code overwrite each other’s result.
  • Fill in Rule Code and Rule Name (marked *), and give every rule its own code.
  • Rules run when someone saves on the add or edit form in App space.
  • A rule runs when its switch is on and it has a script.

Check yourself

A Rule Book entry is set to Warning and its script returns false. What does the person saving the record see?
Show the answer

A Rule Book Check dialog with a Proceed Anyway button. A warning shows in the Rule Book Check dialog. The person can close it, or click Proceed Anyway to save.

Omar's rule script has a typing mistake and throws an error. What happens when someone saves?
Show the answer

The rule counts as a Block and shows the error. An error in the script is treated as a block and the error text is shown. Test a new rule before you leave it switched on.

What's next

Last checked