[SalesForce] Validation rule to check picklist list values is not working if more than one word in picklist value

I have a validation rule on Custom object which validates that if Status != Draft, it should not allow the user to change the employee.

It works fine all the values which has single word like Approved, Declined, etc.. But it is not working for the values have more than one word like Under approval, under verification.

Employee_c is Lookup field
Status
_c is picklist

Validation Rule 01:

NOT(ISPICKVAL(Status__c, "Draft")) && ISCHANGED(Employee__c)

I have tried in different way also.

Validation Rule 02:

NOT(CONTAINS(TEXT(Status__c), 'Draft')) && ISCHANGED(Employee__c) 

But still no use. can you please let me what is wrong with validation rule? or is there any known issues.

Additional Information:

WHen i am using only ISPICKVAL() it is validation rule works fine, but not with ISCHANGED.

Best Answer

PICKVALS have a number of limitations that are often very difficult to work with.

In my experience, a rule that refers to a single value picklist can only refer to the current and previous value PRIORVAL of the picklist in a (valuefield, "textvalue") format. If it's a multi-select picklist, then you can use ISPICVAL(CONTAINS(valuefield, "textvalue1", textvalue2,...) or similar syntax (sorry, but I didn't have time to verify this is the correct way to order this before posting).

If you want the "Does not contain" or Boolean negative", you can use NOT(PICKVAL(valuefield, "textvalue") as an argument in your expression. What I've observed is that if you want if new value AND old value conditions type of validation rule, it's often best to set it up like: AND(ISPICKVAL(valuefield,"textvalue"), PRIORVAL("textvalue")). The editor will expect PRIORVAL to have an ISPICKVAL in front of it, but will only want one ISPICKVAL in the expression if there's two PICKVALS contained in the expression. The help on this is rather vague other than to tell you there are limitations on what you can do with PICKVALS.

Sometimes, it's nearly impossible to create a single validation rule for PICKVALS that address what you're trying to accomplish because they have so many limitations in SF. It can be very trying on one's patience and time-consuming. The syntax is quite different to what we're used to working with in APEX and other languages, or so it seems to me.

Related Topic