Cert++
Close

Validation rules versus automation field updates

Key Takeaway

A validation rule blocks the save and asks the user to fix the data; a field update sets the value automatically. Validation rules check values that before-save record-triggered flows set, but workflow field updates don't trigger validation rules.

A validation rule checks a record's data when someone saves it. If the data breaks the rule, Salesforce blocks the save and shows an error message that tells the user to fix it. Automation such as workflow field updates and record-triggered flows can also change field values, and validation rules never check some of these updates. So you need to know the order of events to choose the right tool and avoid conflicts.

How a validation rule blocks a save

A validation rule contains a formula that describes the bad data you want to stop, not the good data you want. When the formula returns TRUE, Salesforce doesn't save the record, and the user sees the rule's error message.

For example, this formula blocks an Account whose Account Number is filled in but isn't exactly eight characters:

AND(NOT(ISBLANK(AccountNumber)), LEN(AccountNumber) != 8)

The formula returns TRUE when both parts are true. NOT(ISBLANK(AccountNumber)) means the field is filled in, and LEN(AccountNumber) != 8 means it isn't exactly eight characters. So the rule doesn't block an Account with a blank Account Number.

You don't need IF(condition, TRUE, FALSE), because the condition already returns TRUE or FALSE.

You can use functions in a validation rule formula to narrow when the rule applies. For example, you can use ISNEW to apply the rule only when a record is created, or ISCHANGED to apply it only when a field changes.

When one validation rule fails, Salesforce keeps checking the other validation rules and shows all the error messages at once.

Platform App Builder Study Guide

Checklist progress

0/340Learned

Given a scenario, demonstrate the use of validation rules to meet stated business requirements

0/15

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other Platform App Builder studiers. 757 members and growing.