Opportunity field mandatory when an Salesforce Opportunity stage is changed

There are two ways possible to achieve the mandatory requirement for salesforce, one is standard salesforce validation rule and other is custom logic using apex trigger, its depends on the business logics,

for here, we can simply achive for the out of box solution for the salesforce validation rule.

For Example:

AND ( 
OR ( 
ISPICKVAL(StageName, "Closed - Lost to Competitor"), 
ISPICKVAL(StageName, "Closed - No Decision"), 
ISPICKVAL(StageName, "Closed - Project Canceled") 

Use case from Salesforce Community: (Validation Rule not triggering? If we lost, why?)

Also, refer the below youtube video to create a validation rule in opportunity object:

Additional Validation rule in Opportunity:

Example 1:

Prevent user to changing a picklist value in Opportunity.

ISPICKVAL( PRIORVALUE (StageName), "Stage 1"),
ISPICKVAL(StageName, "Stage 3"),
NOT ($Profile.Name = "System Administrator")

Example 2:

Making a field required when an Opportunity stage is changed to closed won or lost

"Closed Won",1, 
"Closed Lost",1, 
0) = 1,

Source from Salesforce:

Written by 

I am Sakthivel Madesh, a certified Salesforce Advanced Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 15x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead 5x Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply

Your email address will not be published. Required fields are marked *