4

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.

4
  • IsPickVal works with multi-word options: help.salesforce.com/….
    – Mike Chale
    Aug 28, 2013 at 14:39
  • Yes Mike. It should work. But in my case it is not working. I have tried similar kind of validation using trigger and it is working properly. What are the other possibilities? I have also tried similar validation rule in my Developer edition. It is working. I think it is related to some other issue in the instance. Thanks :)
    – goodForce
    Aug 29, 2013 at 3:34
  • I have also tried: TEXT(Status__c)<> "Draft" && ISCHANGED(Employee__c)
    – goodForce
    Aug 29, 2013 at 3:47
  • With ISPICKVAL you need to use something like AND(NOT(ISPICKVAL(valuefield, textvalue)),(ISPICKVAL(PRIORVAL(valuefield, textvalue))) I've not verified this exact syntax, but it's in the ballpark (check the SF Help). I was working on something similar just a couple days ago. PICKVALS have a number of limitations that can be a PITA. If it's a multiselect Piclist, you have some other options like CONTAINS.
    – crmprogdev
    Aug 29, 2013 at 5:16

1 Answer 1

2

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.

1
  • Thanks and your answer is gives more information about picklist value validation. Finally I have changed my validation to Trigger.
    – goodForce
    Sep 3, 2013 at 2:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .