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

Why does this rule pass?

I have a validation rule as follows:


Account.RecordTypeName__c <> $RecordType.Name


From the debug log below we can see the values of the 2 fields are not the same (France and OEM1). So why does this validation rule pass? The formula is true so the validation rule should fail and display an error message.


13:47:4.552|VALIDATION_FORMULA|Account.RecordTypeName__c <> $RecordType.Name|$RecordType.Name=France , Account.RecordTypeName__c=OEM1


Account.RecordTypeName is a formula field set to $RecordType.Name.


I am very certain that this rule (which has been place for several months) was working and then  has stopped working. Same rule in both sandbox and production and same failure in both orgs. An interesting note is if I change the formula to be Account.RecordTypeName__c = $RecordType.Name then the validation rule always fails and displays the error message regardless of whether the fields are the same or different.


Can anyone explain this strange behavior?






Steve :-/Steve :-/

I think it's because the VR is being fired before your Account.RecordTypeName__c formula field is being executed.  I think you may need to reference the Account.RecordTypeID



Strange that it used to work. I wanted to stay away from hardcoding RecordTypeIDs in the validation formula as this causes a maintenance issue whenever record types are changed. We use this VR on all of the objects that use record types.If it is because of timing it is strange that the debug log shows the correct value.


If SF supports formula fields in VRs then this should work. If they are not supported then they shouldn't let you create the formula.


Maybe I'll have to submit a support ticket.