How to write validation rule to restrict picklist value choice unless record looks up to a particular record type - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Ryan ShipmanRyan Shipman 

How to write validation rule to restrict picklist value choice unless record looks up to a particular record type

I have been running into an issue the last couple of days building a validation rule. I want to restrict a user from choosing one of the values on a picklist unless that Case is associated with a record of one particular record type in a lookup field further up in the Case. 

This is the formula I wrote for the validation rule:
AND( 
(NOT(Department__r.RecordTypeId="01241000000k92FAAQ")), 
(ISPICKVAL(Visit_Type__c, "New Video Visit")) 
)

For some reason, this formula is evaluating as true every time the record is saved, even when the Department lookup field is filled with a value which should have the Record Type ID listed in the formula, triggering the validation error, and not allowing the record to be saved when it should be possible. 

Previously, I have made similar types of formulas, but have gone a level deeper, and referenced the developer name of the record type (e.g Department__r.RecordType.DeveloperName=). Unfortunately, I have reached the maximum level of object references in my Case object, so that’s not a solution available to me going forward. 

Would appreciate any ideas, illuminations on something I’m missing, or alternatives.
Best Answer chosen by Ryan Shipman
Waqar HussainWaqar Hussain
Try this
AND( 
(NOT(Department__r.RecordTypeId="01241000000k92F")), 
(ISPICKVAL(Visit_Type__c, "New Video Visit")) 
)

 

All Answers

Waqar HussainWaqar Hussain
Try this
AND( 
(NOT(Department__r.RecordTypeId="01241000000k92F")), 
(ISPICKVAL(Visit_Type__c, "New Video Visit")) 
)

 
This was selected as the best answer
Ryan ShipmanRyan Shipman
Well, easy as that, thanks for the help. 
Steve MolisSteve Molis
User-added image