function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dev_jhdev_jh 

Validation rule on PICKLIST

I must be doing something wrong, as I can´t believe this is so complicated.

I want to add a "Reason Lost" to my Opportunities. This new field will be a picklist.

I want to validate that, if the status is changed to "Closed - Lost" a "Reason Lost" must be entered.

If I have 3 reasons, let´s say: "Price", "Service", "Cancelled Operation"

Do I really need a formula like this?

AND(ISPICKVAL(Status, "Closed - Lost"), NOT(OR(ISPICKVAL(ReasonLost__c,"Price"),ISPICKVAL(ReasonLost__c,"Service"),ISPICKVAL(ReasonLost__c,"Cancelled Operation"))))

I would have hoped for a much simpler:

AND(ISPICKVAL(Status, "Closed - Lost"), NOT(ISNULL(ReasonLost__c)))

What am I doing wrong? or is this a limitation? (I can´t imagine if I want to do this for a picklist with 100 values!)

Thanks all!
heatherwebsterheatherwebster
As far as I know, you can't use Null for Picklist values.  You have to use NOT and list all the values.  If you find out otherwise I'd love to know because it's not fun when a picklist value changes and you forget to update the validation rule.
Heather
anup_aanup_a
You can use this validation rule in such a scenario:

AND(ISPICKVAL(StageName, "Closed Lost"), ISPICKVAL(Reason_Lost__c, ""))

The rule will check if the Stage = Closed Lost and no value has been selected in the Reason Lost field and will throw an error message.
dev_jhdev_jh
Thanks a bunch, I will certainly try it... will save a lot of time. Ta!
anup_aanup_a
Grt! Lemme know how it goes :)