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
chris lim 15chris lim 15 

validation rule to block a field from editing if another picklist has not the good value

Hi, if opportunity type picklist is A, B and C related to an other custom object type picklist has 1,2 and 3. the opportunity can not take the value C if the custom object is not 3.
Can you help me with this validation rule ?
Thank you
Best Answer chosen by chris lim 15
SwethaSwetha (Salesforce Developers) 
HI Chris,
I see this question was also posted on https://salesforce.stackexchange.com/questions/406214/validation-rule-to-block-one-field-from-editing-if-another-field-has-a-value

Try
AND(
ISPICKVAL(Opportunity.Type, "C"),
NOT(ISPICKVAL(Custom_Object__c.Picklist_Field__c, "3"))
)

This formula checks if the Opportunity Type picklist value is "C" and if the related Custom Object Picklist Field value is not "3". If both conditions are true, the validation rule will fire and prevent the editing of the Opportunity field.

If this information helps, please mark the answer as best. Thank you

All Answers

SwethaSwetha (Salesforce Developers) 
HI Chris,
I see this question was also posted on https://salesforce.stackexchange.com/questions/406214/validation-rule-to-block-one-field-from-editing-if-another-field-has-a-value

Try
AND(
ISPICKVAL(Opportunity.Type, "C"),
NOT(ISPICKVAL(Custom_Object__c.Picklist_Field__c, "3"))
)

This formula checks if the Opportunity Type picklist value is "C" and if the related Custom Object Picklist Field value is not "3". If both conditions are true, the validation rule will fire and prevent the editing of the Opportunity field.

If this information helps, please mark the answer as best. Thank you
This was selected as the best answer
chris lim 15chris lim 15
Thank you Swetha it's working.