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
Arjun SrivastavaArjun Srivastava 

Generic Validation Rule with picklist values

I have a picklist named as 'Status' on Lead object.
picklist Field status have values as : 'New','Cold','Process','Dead'.

Once user has selected status as 'Cold',he can't go back and select 'New' as a value instead he is allowed to select 'Process' or 'Dead' as a new value. I want to make this happen using validation rule. Please help.
I have written this:


AND(ISPICKVAL(PRIORVALUE(Status),"Process"),OR(CONTAINS(TEXT(Status),"New"),CONTAINS(TEXT(Status),"Cold")))


Is there any other good approach to do this?
Can i also get the values of picklist in a generic way without hardcoding the picklist values in a validation rule.

 

Thanks!

Satish_SFDCSatish_SFDC

 

 

AND( 
ISPICKVAL(PRIORVALUE(Status),"Cold"), 
ISPICKVAL(Status,"New") 
)

 

If you want to get the values of the picklist dynamically, you would have to use describe methods in apex. Although you cannot use them in validation rules, you can write triggers for your requirement.

 

Hope this helps!
Regards,
Satish Kumar
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.

Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi,

 

If your requirement is to restrict while editing a record then you can achieve this by the following condition in validation rule,

 

AND(
ISPICKVAL(PRIORVALUE(Status),"Cold"),
ISPICKVAL(Status,"New")
)

 

Because your condition is meant to check a previous value. So, previous value can be checked when a value is already there (saved). 

 

Hope this will make your idea clear.