+ Start a Discussion
AnonymouseAnonymouse 

How to validate if a custom picklist field currently has particular values with validation rules

Hello,

I currently have a custom picklist field with several choices. In case a user tries to edit the object, I want to make sure that the choices they may change the picklist to is limited to only a couple choices depending on what the value was originally. 

I want an error to pop up in case something else was picked before trying to edit the record to "End". For instance, the only acceptable choices before changing to "End" would be either "Beginning" or "Middle." 

For instance, if the original value was "Never Started," then I want an error to popup.

This is what I have currently for a validation rule:
 
AND( ISPICKVAL( customField__c, 'End') , 
OR( ISPICKVAL( customField__c , 'Beginning'), 
ISPICKVAL( customField__c , 'Middle')
) 
)

Any help would be greatly appreciated.

Sincerely,
Jackie
Best Answer chosen by Anonymouse
Narender Singh(Nads)Narender Singh(Nads)
Hi,

Try this:

ISPICKVAL(customField__c,"End")
&&
NOT(  (  ISPICKVAL(PRIORVALUE(customField__c),"Beginning")
           ||
           ISPICKVAL(PRIORVALUE(customField__c),"Middle")
           )
        )
 

All Answers

Raj VakatiRaj Vakati
Use this one
 
AND(
ISPICKVAL(PRIORVALUE(customField__c),"End"),
OR(
ISPICKVAL(customField__c, "Beginning") ,
ISPICKVAL(customField__c, "Middle") 
)

)

 
Narender Singh(Nads)Narender Singh(Nads)

Hi,
Example: For instance, the only acceptable choices before changing to "End" would be either "Beginning" or "Middle." 
The Validation formula will look like this:

(  ISPICKVAL(PRIORVALUE(customField__c),"Beginning")
   ||
   ISPICKVAL(PRIORVALUE(customField__c),"Middle")
)
&&
(   ISCHANGED(customField__c)
    && 
    NOT(ISPICKVAL(customField__c,"End"))
)

Let me know if it helps.
Thanks

AnonymouseAnonymouse
Hi Raj and Narender,

I'm afraid it's still not working.

Sincerely,
Jackie
Narender Singh(Nads)Narender Singh(Nads)
Hi,

Try this:

ISPICKVAL(customField__c,"End")
&&
NOT(  (  ISPICKVAL(PRIORVALUE(customField__c),"Beginning")
           ||
           ISPICKVAL(PRIORVALUE(customField__c),"Middle")
           )
        )
 
This was selected as the best answer
AnonymouseAnonymouse
Hi Narender,

You are my hero. :) It works beautifully!

Sincerely,
Jackie
Narender Singh(Nads)Narender Singh(Nads)
Hehe, am glad it worked. :)