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
RAFAEL SANCHEZ 15RAFAEL SANCHEZ 15 

Validation Rule for all record types except one

Hi guys! I am working on an internal project and I find myself with 7 different record types. I have created around 25 validation rules that I want them to apply to all record types except one. 

I have tried something like this: 
AND( ABI_SFA_Record_Type_Name__c  <> 'ABI_SFA_Template', ISPICKVAL(ABI_SFA_Country__c ,'GB'), LEN( ABI_SFA_ZIP_Postal_Code__c ) > 9)

Unfortuntely, it is not properly working. 

Any hints?

Thank you!!
NagendraNagendra (Salesforce Developers) 
Hi RAFAEL SANCHEZ 15,

A better way to handle this requirement is to use GLOBAL variable - $RecordType and use Record Type NAME instead of hard coding Record type ids in Validation. Record Type Id may change if you migrate the Validation rule to different org, and record name should stay identical.
 
While defining Validation rule, Click on --> "Insert Field" button where all available global variables are listed with $ prefix. Select - $RecordType, there are 4 field names under it.
 
Select --> $RecordType.Name (Type - "Text)". use the actual record name value in the validation rule.
 
Hope the above explanation and the reason for using record type name in such cases is clear to you.

Please let us know if you still have any issues.

Kindly mark it as solved if it helps you.

Best Regards,
Nagendra.P
srivanisrivani
Try the below one

AND(RecordType.DeveloperName <> 'ABI_SFA_Template', ISPICKVAL(ABI_SFA_Country__c ,'GB'), LEN( ABI_SFA_ZIP_Postal_Code__c ) > 9)
I believe ABI_SFA_Template is record type developer name.