DEV Community

Cover image for Salesforce Validation Rules: 6 Patterns Every Admin Should Have Ready
Rohan Mehta
Rohan Mehta

Posted on

Salesforce Validation Rules: 6 Patterns Every Admin Should Have Ready

Validation rules are the cheapest guardrail in Salesforce. No code, no Flow, no deployment headache — just a formula that says "not on my watch" and stops bad data before it ever gets saved. If your org has none, start with these six patterns. They cover the mistakes users actually make.

1. Stop closing Opportunities with missing details

AND(
  ISPICKVAL(StageName, "Closed Won"),
  OR(ISBLANK(CloseDate), ISBLANK(Amount))
)
Enter fullscreen mode Exit fullscreen mode

Closed Won with no amount and no close date is a pipeline fantasy. This one keeps your forecast honest.

2. Block backdated Cases

CreatedDate - 7 > DateOpened__c
Enter fullscreen mode Exit fullscreen mode

Service teams backdate cases to "fix" SLAs. Seven days of grace is generous; anything older gets rejected with a clear error message.

3. Keep dates in a sane order

CloseDate < CreatedDate
Enter fullscreen mode Exit fullscreen mode

It sounds obvious, but records with a close date older than their creation date show up in real orgs all the time. One line of formula, problem gone.

4. Lock the picklist journey

AND(
  ISCHANGED(Status),
  ISPICKVAL(PRIORVALUE(Status), "Closed"),
  NOT($User.Bypass_Validations__c)
)
Enter fullscreen mode Exit fullscreen mode

A closed record should not quietly slide back to "New". Let the exception be a real permission (a custom field on the user), not whoever clicks fastest.

5. Require a reason when priority changes

AND(
  ISCHANGED(Priority),
  ISPICKVAL(Priority, "High"),
  ISBLANK(Priority_Reason__c)
)
Enter fullscreen mode Exit fullscreen mode

High-priority anything without a written reason is noise. This one forces the one sentence that makes escalation actually useful.

6. Protect records mid-approval

AND(
  Approval_Status__c = "In Review",
  ISCHANGED(Amount)
)
Enter fullscreen mode Exit fullscreen mode

Editing amounts while a discount approval is in flight is how revenue leaks. Freeze the fields that the approval is about.

Make the errors useful

A validation rule is only as good as its error message. Three habits:

  • Name the rule clearly and fill in the Description field — future-you will thank present-you during the next audit.
  • Put the error at the field level, not the top of the page, so the user sees exactly what to fix.
  • Say what to do, not what went wrong. "Close date can't be in the past — pick a future date" beats "Invalid value".

If you'd rather force the entry at the field level instead of blocking on save, here's a walkthrough of the six ways to make a field required in Salesforce. And when the answer isn't blocking at all but nudging the right person, Flow-based custom notifications handle that better than any rule.

Validation rules won't fix a messy org by themselves, but they stop the bleeding. Add these six, watch your data quality reports for a month, and you'll wonder why you waited.


Originally published at Way2Force

Top comments (0)