Sub topic 12
Enforcing stage requirements with validation rules and automation
This chapter assumes you can navigate Setup, know the Opportunity fields (Stage, Amount, Close Date, Next Step), and understand that a sales process controls which stages appear on an opportunity. Here you will make the stage model enforce itself.
Why enforce at the stage level
Path guidance tells reps what to fill in. It does not stop them from skipping it. A validation rule is a formula that blocks a save when the formula returns true. Tying the rule to the Stage field lets you require data only when a deal reaches the point where that data should exist.
Writing a stage-based validation rule
Go to Setup, then Object Manager, then Opportunity, then Validation Rules, then New. The formula must return TRUE when the data is bad. This is the most common source of mistakes: the rule describes the error, not the goal.
This rule blocks saving an opportunity in the Negotiation/Review stage unless Next Step is filled in:
AND(
ISPICKVAL(StageName, "Negotiation/Review"),
ISBLANK(NextStep)
)Three details matter here:
StageNameis a picklist, so you cannot compare it with=. UseISPICKVAL(StageName, "value").- The string must match the stage's API value exactly, including the slash and capitalization. If an admin renames a stage label, check whether the value changed.
- When you create the rule, set an error message that tells the rep what to do, such as "Enter a Next Step before moving to Negotiation/Review." Set the error location to the Next Step field so the message appears next to it.
Limiting a rule to one sales motion
If you have several sales processes, a rule on StageName applies to every opportunity. To limit it to one record type, add a condition on RecordType.DeveloperName:
AND(
RecordType.DeveloperName = "New_Business",
ISPICKVAL(StageName, "Negotiation/Review"),
ISBLANK(NextStep)
)Use the developer name rather than the label so the rule survives a rename. Confirm the developer name in the record type's detail page.
Where validation rules fall short
Validation rules run on every save, including data loads, API calls, and automation. That is useful, but it has costs:
- A rule that fires during a bulk load rejects those rows. Plan for this before importing historical data, or add a bypass condition such as a custom checkbox or permission check.
- Rules only see the record being saved. They cannot easily compare against the previous stage unless you use
PRIORVALUE(StageName)orISCHANGED(StageName). - Error messages are the only guidance. A rep who sees a vague message will not know what to fix.
Automation on stage change
Use a record-triggered flow when you want the system to act, not block. Typical uses include creating a follow-up task, notifying a manager, or setting a field when a deal reaches a stage. In Flow Builder, choose a record-triggered flow on Opportunity, run it when a record is created or updated, and add the entry condition that Stage is changed. Without the "is changed" condition, the flow fires on every edit.
Choose between the two tools using this table:
| Need | Use |
|---|---|
| Stop the save until data is present | Validation rule |
| Create a task or send a notification | Record-triggered flow |
| Fill in a field automatically | Record-triggered flow |
| Show reps what to complete | Path key fields and guidance |
Testing
Test with a rep-level user, not only as an administrator. Try each stage transition, including skips and a move into Closed Lost. Check that error messages appear on the right field.
Exercise
A rule uses the formula AND(StageName = "Closed Won", Amount = 0) and Salesforce refuses to save it. What are two problems with it?
Show answer
StageName is a picklist, so it must be tested with ISPICKVAL(StageName, "Closed Won") rather than =. Also, Amount can be blank rather than zero, so OR(ISBLANK(Amount), Amount = 0) is a safer check for missing data.
Exercise
You want a task created for the account owner whenever an opportunity moves to Proposal/Price Quote. Do you use a validation rule or a record-triggered flow, and what entry condition keeps it from firing on every edit?
Show answer
Use a record-triggered flow on Opportunity. Add an entry condition that Stage is changed and equals Proposal/Price Quote.