Home SALESFORCE Opportunity field mandatory when an Salesforce Opportunity stage is changed

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") 
), 
ISBLANK(Why_we_lost__c) 
)

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.

AND(
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

AND(
OR(
ISNEW(),
ISCHANGED(StageName),
ISCHANGED(Competitor__c)
),
CASE(StageName, 
"Closed Won",1, 
"Closed Lost",1, 
0) = 1,
ISBLANK(Competitor__c)
)

Source from Salesforce:
https://help.salesforce.com/articleView?id=fields_about_field_validation.htm&type=0

You may also like

Leave a Comment