#Trailhead #Salesforce Admin #Validation Rule
Suppose a business wants to prevent users from saving an Opportunity without entering the Amount field. How would you implement this using a Validation Rule, and what conditions would you use?
Hi @Rohith thammali Good question! We can easily handle this requirement using a Validation Rule without writing any Apex code.
Steps:
- Go to Setup → Object Manager → Opportunity.
- Select Validation Rules → New.
- Enter the formula:
ISBLANK(Amount)
- Error Message: Please enter the Opportunity Amount before saving.
- Set the error location to the Amount field, save, and activate the rule.
Real-time scenario:
Suppose the sales team must enter the Amount for every Opportunity to maintain accurate sales pipeline reports. This validation rule prevents users from saving an Opportunity when the Amount is blank.
My suggestion: If the Amount is mandatory only at a particular stage, such as Proposal or Negotiation, combine AND() with ISPICKVAL() to apply the validation only at that stage.
One important point: Blank and Zero are different. ISBLANK(Amount) allows 0. If the business requires a positive Amount, use OR(ISBLANK(Amount), Amount <= 0).