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
VirijaVirija 

Validation rule involving picklist values

Hi I am new to salesforce. I am facing a diffcult situation with a validation rule that is involving picklist values. I have a Picklist field called XYZ category. I have 7 different picklist values like Phase, emergency, authorized, operations, other, members, procedures. Phase, emergency, authorized, operations can be considered as important for the sake of scenario. I want a validation rule that should allow users to pick any of the 7 values in the xyz category which normally happens. I do not want the users to change the category if they once select Phase, emergency,authorized, operations. If they select anything from the other three and they wish to edit and change it to another category the system should allow saving the record. If they change the category from other or procedures or members to the important ones it should allow saving, but if they wish to change from the phase or emergency or authorized or operations to any ther category, the system should not allow saving the record.

 

 

I am trying to solve it using Priorvalue, ischanged......but I am not reaching the solution. Can some one help me please...

Shailesh DeshpandeShailesh Deshpande
HI,

heres the formula for your validation rule:

IF (PRIORVALUE(TEXT(XYZCategory__c)) == "Phase"
|| PRIORVALUE(TEXT(XYZCategory__c)) == "Operations"
|| PRIORVALUE(TEXT(XYZCategory__c)) == "Authorized"
||(PRIORVALUE(TEXT(XYZCategory__c)) == "Emergency"
, TRUE, FALSE
)

Havent tested.. But should work.
VirijaVirija

Unfortunately that is not working. Can you help me with a trigger in this case? Thank you for your support.

Shailesh DeshpandeShailesh Deshpande
TRIGGER is not required in this case. Does this formula get saved? I suppose in validation rule we need to use = instead of ==. Can you try that?
VirijaVirija

That is not working. When IF is used the system is not allowing to use OR in the condition,  but it is allowing OR in True, False. I have used four different validation rules and the functionality is working now.

 

Thank You for your help.