1

I have a problem that in my validation rule. I have a picklist field called "Status". It contains value like,"Progress,Completed,Won,Lost".

If picklist prior value is "progress", then i want choose only completed. Not won and lost.

But I'm not able to choose progress when create a new record. I can able to choose,"won" and "lost" only. What is wrong in my validation rule.

This is my formula:

OR( 
AND 
( 
ISPICKVAL(PRIORVALUE(Status__c),"Progress"), NOT(ISPICKVAL(Status__c,"Complete")) 
), 
AND 
( 
ISPICKVAL(PRIORVALUE(Status__c),"Completed"), NOT(ISPICKVAL(Status__c,"Won")) 
) 
)

Any help much appreciated. Thank you.

3

Salesforce documentation is a great help here.

When users create a new record, this function returns the value of the field referenced rather than null. For example, if you create an account named “Acme,” PRIORVALUE(Account.Name) returns Acme.

So when you create a new record and choose "progress"

AND 
( 
ISPICKVAL(PRIORVALUE(Status__c),"Progress"),NOT(ISPICKVAL(Status__c,"Complete")) 
)

returns true because PRIORVALUE(Status__c) equals "Progress"

Try changing this formula to something like:

AND 
( 
ISPICKVAL(PRIORVALUE(Status__c),"Progress"), NOT(ISPICKVAL(Status__c,"Complete")), NOT(ISNEW()) 
)

ISNEW function will return true if this is a new record and this validation will nor fire.

| improve this answer | |
  • It's working when a new record created with progress. But After edit record I'm not able to choose completed. – Jana Shree Mar 28 '16 at 4:28
  • I'm not sure what picklist values you have. In your formula you have "Complete" and "Completed", it might be that you need to change complete to completed in the above example. – Oles Malkov Mar 28 '16 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.