Using Data Validation Rules to require a field after a different field has changed to a certain value. - Answers - Salesforce Trailblazer Community
Ask Search:
Caleb WillsCaleb Wills 

Using Data Validation Rules to require a field after a different field has changed to a certain value.

I am currently trying to make it so that if the stage field(Picklist) on the opportunity object gets changed to "Closed Lost", then make the picklist field "Loss Reason" required. This is my current formula (I'm a complete novice with doing this stuff so I'm likely way off. Any help is appreciated)

AND(
  ISPICKVAL(StageName, "Closed Won"),
NOT(ISBLANK(Loss_Reason__c)))

I'm getting the error about Loss Reason a picklist field but I frankly have no idea where to go from here.
Best Answer chosen by Caleb Wills
Rushita BavishiRushita Bavishi

Hi Caleb,
Your validation rule is incorrect . You are firing validation ruule on not null values.Try with this:
AND( ISPICKVAL(StageName, "Closed Lost"), ( ISPICKVAL(Loss_Reason__c."") ) )

All Answers

Caleb WillsCaleb Wills
That should be "Closed Lost" guess I wasn't paying attention to that at the time.
Andrew GillanAndrew Gillan
If Loss_Reason__c is a Picklist, you can't use a straight ISBLANK.
 
AND(
  ISPICKVAL(StageName, "Closed Won"),
  NOT(ISBLANK(TEXT(Loss_Reason__c)))
)

an alternate is to try:
AND(
  ISPICKVAL(StageName, "Closed Won"),
  NOT( ISPICKVAL(Loss_Reason__c."") )
)
but i generally find I have less issues, and the intent is clearer, if I use the ISBLANK 

Regards

Andrew

 
Rushita BavishiRushita Bavishi

Hi Caleb,
Your validation rule is incorrect . You are firing validation ruule on not null values.Try with this:
AND( ISPICKVAL(StageName, "Closed Lost"), ( ISPICKVAL(Loss_Reason__c."") ) )

This was selected as the best answer