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
PB14PB14 

Validation Rule - If picklist value is a, b, or c then it can not be changed to X

Hello,

I have a picklist field that contains values A-Z. I need to write a validation rule that says if the Picklist is set to A, B or C then the same Picklist can't be changed to the value X but can be changed to other values. 

OR(
AND(
ISPICKVAL(PRIORVALUE( VPM_Field__c ),"A"), NOT(ISPICKVAL(VPM_Field__c,"X))
),
AND(
ISPICKVAL(PRIORVALUE(VPM_Field__c),"B"), NOT(ISPICKVAL(VPM_Field__c,"X")))
),
AND(
ISPICKVAL(PRIORVALUE(VPM_Field__c),"C"), NOT(ISPICKVAL(VPM_Field__c,"X")))
)


The above is what i have but it doesnt work 

Thanks 

 
Jim JamJim Jam
This might work ....

OR(
AND(
ISPICKVAL(PRIORVALUE( VPM_Field__c ),"A"), ISPICKVAL(VPM_Field__c,"X")
),
AND(
ISPICKVAL(PRIORVALUE(VPM_Field__c),"B"), ISPICKVAL(VPM_Field__c,"X")
),
AND(
ISPICKVAL(PRIORVALUE(VPM_Field__c),"C"), ISPICKVAL(VPM_Field__c,"X")
)
)


Then again, it might not.
Wade Lovell 4Wade Lovell 4
Check https://developer.salesforce.com/forums/ForumsMain?id=906F000000092PxIAI for assistance.
Girija Joshi 14Girija Joshi 14
Just remove NOT because with Not you are checking if previous value is A,B or C and current is not X (anything else other than x) then not allowed to change. If you want previous value A,B,C and current value is X then if don't want to change then just remove NOT from your code.