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
icemft1976icemft1976 

validation formula for an empty picklist

    I figured this would have been answered by doing a forum search but no luck:

How do I make a picklist field 'required' with a validation rule? 

I tried using both ISPICKVAL and CASE to detemrine when a picklist had not value selected, but either I get "invalid argument" (case) or no match (ISPICKVAL).

CASE example:

IF(  AND(Extension_Date__c <> null,   CASE(Extension_Reason__c, "Budget", false, "Org Change", false, true) ) , true, false)

ISPICKVAL example:

IF( AND(Extension_Date__c <> null,   ISPICKVAL(Extension_Reason__c, "" ***) ), true, false)

***[ also tried NULL, "NONE",etc]

Can this only be done using a NOT check on every picklist value? Seems cumbersome....   i.e.

IF AND(Extension_Date__c <> null,  NOT(ISPICKVAL(Extension_Reason__c, "Budget")), NOT(ISPICKVAL(Extension_Reason__c, "Org Change")) ), true, false)


Thanks,
ajd
werewolfwerewolf
See the following thread:

ISPICKVAL can now detect a null picklist value (i.e., "None Selected")
http://forums.sforce.com/sforce/board/message?board.id=discuss&message.id=1906
werewolfwerewolf
Anyway, what are you doing with the IF statement?  It seems to have no function here.

I think what you're actually getting at is:

AND(Extension_Date__c <> null, ISPICKVAL(Extension_Reason__c,""))

This will return true if the extension date is specified but nothing is specified in Extension Reason (or if something is in Extension Reason and nothing is in Extension Date).  No IF required.
icemft1976icemft1976
Thanks Werewolf, I appreciate the link and the follow up!

the IF statement you see applied to a couple other conditions in the validation rule, but it is extraneous in the context of this discussion - sorry about that.

So I tried your formula (that's actually the first thing I tried) and no luck. Have you ever been able to actually make a null picklist check work in your SF  instance? I can't make this any simpler, i just have

AND(Extension_Date__c <> null, ISPICKVAL(Extension_Reason__c,""))


but I must be missing something because it doesn't throw an error when a I edit a contract, add an extension date but leave the reason blank.

Frustrating....
werewolfwerewolf
Well, I don't know what the issue might be then.  I do have a validation rule with an empty ISPICKVAL, that's working as expected for me.  In fact, just because I have way too much time on my hands :), I tried making a setup identical to yours, and it worked.  The only difference between my formula and yours is I'm using ISNULL, so:

Code:
AND( NOT ( ISNULL ( TestDate__c) ), ISPICKVAL( Pick1__c,""))

And hey -- did you make sure the Active box on your validation rule is turned on?
icemft1976icemft1976
Thanks for your time and your help....as usual, it's the thing that I wasn't looking at that seemed to be causing the problem.

Whne I changed the Date check from "Extension_Date__c <> null" to "NOT ( ISNULL ( Extension_Date__c  ) )" everything worked fine. Weird.

Thank again!
Julio DavilaJulio Davila
Try to use these functions

ISBLANK(TEXT( Picklist field ))

I hope will work
Russell baker 1Russell baker 1

ISBLANK(TEXT( Picklist field )) works absolutly fine.
Ajay ChakradharAjay Chakradhar
Try this  AND(ISPICKVAL(Picklist_1 ,"String1"),ISBLANK(TEXT(Picklist_2)))  ....ISBLANK(TEXT(Picklist_2) will check whether Picklist_2 is BLANK or NOT
Sara Adelizzi 6Sara Adelizzi 6
Hello -
My Validation rule is not catching when my Picklist field is blank.
I'm following the above suggestion - ISBLANK (TEXT (picklistfield__c)
It saves the record with Record Type, Checkbox and Date, but Picklist field is blank
What am I doing wrong here?
Here's the rule:
AND( 
RecordType.Name = "AFC", 
Inactive_Consumer__c, 
ISBLANK( TEXT( Reason_Deactivated__c )), 
ISBLANK( Inactive_Effective_Date__c) 
)
Frustrating!!
Thanks
Wade Lovell 84Wade Lovell 84
Old thread but maybe this will help someone in the future. There isn't a condition above for the "Inactive_Consumer__c" field. 
Try this instead:

AND( 
  RecordType.Name = "AFC", 
  Inactive_Consumer__c = TRUE, 
  ISBLANK( TEXT( Reason_Deactivated__c )), 
  ISBLANK( Inactive_Effective_Date__c) 
)

Make it a great one,
Wade 'Smokey' Lovell 
Siddharth Jain 64Siddharth Jain 64
It seems AND does not work well with picklist, try using OR conditions instead, that should definately work.