Create versus edit functions in validation formulas
Key Takeaway
Use ISNEW() to apply a rule when a record is created and ISCHANGED to apply it when a field changes. ISCHANGED returns FALSE on a new record, so pair it with ISNEW() when a rule should cover both.
A validation rule stops a save when its formula returns TRUE. Some business rules should apply only when a record is created, only when it is edited, or only when a certain field changes. The functions ISNEW(), ISCHANGED, and PRIORVALUE tell the formula which of these is happening, so the rule fires only in the right scenario.
What each function returns on create and on edit
A validation rule formula returns TRUE or FALSE. When it returns TRUE, the user sees the rule's error message and can't save the record. Three functions let the formula react to the type of save:
| Function | When a record is created | When an existing record is edited |
|---|---|---|
ISNEW() | Returns TRUE | Returns FALSE |
ISCHANGED(field) | Returns FALSE for every field | Compares the field's current value to its previous value and returns TRUE if they differ |
PRIORVALUE(field) | Returns the field's current value, not null | Returns the field's previous value |