How-to

How to write a validation rule

A validation rule stops a record saving when something about it is wrong, and tells the person why.

Try it live on this page

Before you start

You need to be one of your CRM's admins.

Interactive

Try it: build a validation rule

This runs Chaudie's real rule engine on a sample deal. Build a rule, change the deal, and watch the save get blocked or go through.

Block the save when

  1. 1
  2. 2

Chaudie writes this as the formula AND(ISPICKVAL(stage, "Won"), ISBLANK(close_date))

A sample deal

Saved as: Proposal, $18,000, 10% discount, no close date. This save changes the stage.

  1. 1

    Open Validation Rules

    Open your CRM, then your account menu in the corner, then Company Studio. Studio is for your CRM's admins. Choose Validation Rules, then choose a module on the left, then New Rule.

  2. 2

    Name it

    Give it a Rule name, and a Description so others know why it exists.

  3. 3

    Say when to block the save

    Under Block the save when, choose Add condition and build it from fields and values. Prefer to type it? Choose As a formula, for example AND(ISPICKVAL(stage, "Closed Won"), ISBLANK(close_date)). Or choose Write it with AI and describe the rule in plain words.

  4. 4

    Write the message

    The Error message is what people see, so make it an instruction: "A won deal needs its close date."

  5. 5

    Choose where it shows

    Show the error At the top of the form, or beside the field it's about.

  6. 6

    Try it, then save

    Preview on a real record to see whether it would be blocked or would save. When it reads right, save it.

Tips

  • In formulas, names are API names (close_date, not Close date). Reach a linked record's field with a dot.
  • A rule blocks when its condition is true. Write the condition as the thing that's wrong.
  • Required fields don't need a rule: mark the field Required instead.

Questions

What formula language is it?+

Spreadsheet-style functions such as AND, OR, ISBLANK and ISPICKVAL, close to what other CRMs use.

Do rules apply to imports?+

Yes. Imported rows are checked against the same rules, and rows that fail are held back with the reason.

Can I switch a rule off?+

Yes, without deleting it.

More to read

Start with the interview.

You'll see exactly what we'd build before anything is built.

Build my CRM