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
AKenAKen 

Picklist validation rule

Hello All,

 

I'm hoping someone could help me here...

 

I'm trying to write a validation rule that flags a custom picklist field (Primary Win Reason) to be populated once the stage reaches a Win level (we have a "unusual" naming convention, and have 2 types of wins - outlined below).  Here's what I wrote:

 

AND (
OR (
ISPICKVAL(StageName, "7.0 Transition - Win"),
ISPICKVAL(StageName, "7.0 Transition - Win with Exception")),
ISBLANK( PrimaryWinReason__c )

 

Problem is, I get the following error:

 

Error: Field PrimaryWinReason__c is a picklist field. Picklist fields are only supported in certain functions. Tell me more

 

Help please?!?

Best Answer chosen by Admin (Salesforce Developers) 
Steve :-/Steve :-/

Okay, if your other field is also a Picklist you can't use the ISBLANK function unless you convert it to a Text String.  Try something like this instead.

 

 

 

AND(IsWon,
ISPICKVAL(PrimaryWinReason__c, ""))

All Answers

Steve :-/Steve :-/

If you want the Opportunity.PrimaryWinReason__c field to be required any time an Opportunity is won, regardless of the Stage picklist value selected you can ignore the Opportunity.StageName field altogether and just evaluate the Opportunity.IsWon Boolean field in your formula.  

 

AND(IsWon,ISBLANK(PrimaryWinReason__c ))

 

 

 

AKenAKen

Thanks so much for the help!  I tried the formula you suggested, and it still gave me the picklist error - any suggestions?  Does it matter that the Primary Win Reason is a picklist?  I would think that it is just verifing that it is blank...

 

Thanks again for your help!

 

Field PrimaryWinReason__c is a picklist field. Picklist fields are only supported in certain functions. Tell me more

Steve :-/Steve :-/

Okay, if your other field is also a Picklist you can't use the ISBLANK function unless you convert it to a Text String.  Try something like this instead.

 

 

 

AND(IsWon,
ISPICKVAL(PrimaryWinReason__c, ""))
This was selected as the best answer
Pradeep_NavatarPradeep_Navatar

- Picklist fields can only be used in the following functions:

 

    * ISPICKVAL—Compares the value of a picklist to a single value.

    * CASE—Compares the value of a picklist to multiple values.

    * TEXT—Converts a picklist value into a text value so that you can work with the value in functions that support text value,  such as CONTAINS. (Only available in formula fields, validation rules, and workflow field updates.)

 

            AND (

            OR (

            ISPICKVAL(StageName, "7.0 Transition - Win"),

            ISPICKVAL(StageName, "7.0 Transition - Win with Exception")),

            TEXT(PrimaryWinReason__c) <> "unusual")

 

            It will show an error message if StageName = "7.0 Transition - Win" OR "7.0 Transition - Win with Exception"

            and PrimaryWinReason__c != unusual.

AKenAKen

Worked like a charm...thank you! 

 

To do the same with a Loss, would I just have to change "IsWon" to "Is Loss"?

Steve :-/Steve :-/

No there isn't an IsLost boolean field, you have to evaluate IsClosed = TRUE and IsWon = FALSE like this.  

 

AND (IsClosed ,
NOT(IsWon),
ISPICKVAL( Loss_Reason__c ,""))

 

 

AKenAKen

Thanks Stevemo...the code was accepted, but it doesn't flag the field if left blank when saving the opportunity.  I think I may have some more tweaking to do.  Any ideas of why it isn't working would be great. 

 

Thanks so much for your help on this - you are a lifesaver!

Steve :-/Steve :-/

That VR Formula came directly from my SFDC.org, we use it all the time and it works fine.  

What is the API Field Name and datatype of your Loss Reason field on your Opportunity object?  Can you post the VR Formula that you're using? 

AKenAKen

Sure - I think this is what you are asking for:

 

Field LabelPrimary Loss ReasonObject NameOpportunity
Field NamePrimaryLossReasonData TypePicklist
API NamePrimaryLossReason__c 

 

And here is the formula I'm using (again, the syntax checks out, but when I apply it, it's not working like the Primary Win Reason one did.

 

AND (IsClosed,
NOT(IsWon),
ISPICKVAL( PrimaryLossReason__c  ,""))

Steve :-/Steve :-/

What is the Opportunity Stage that you are selecting that should cause the error is Loss Reason is left blank?  And can you verify in the Opportunity Stage configuration that the Stage you're selecting does equal Closed = TRUE and WON = FALSE?

AKenAKen

Again, we have a strange naming convention...here's the 3 stages of Loss:

 

7.0 Transition - LossClosed/Lost0%OmittedAssigned dynamically
7.0 Transition - No BidClosed/Lost0%OmittedAssigned dynamically
7.0 Transition - No DecisionClosed/Lost0%OmittedAssigned dynamically

 

They are all Closed/Lost as a type, as opposed to the Closed/Won for our wins.

 

Is that what you are referring to regarding the Opportunity Stage Config?