[SalesForce] Validation Rule on Lookup Field

I'm trying to validate a Lookup field so that the CONTACT I add to the field has the same CONTACT.ACCOUNT.CUSTOMID as the ACCOUNT governing the record I'm adding the CONTACT to.

To be more specific, I'm comparing two value in the Validation Rule formula:

Resource_Name__r.Account.ScopeTrack_Employer_Number__c
= Budget__r.Connected_Relationship__r.Agency__r.ScopeTrack_Employer_Number__c

This image confirms that before I added the validation rule, the two values are the same (I'm testing with the CUSTOMID = 1 for the Account. But after applying the validation rule, i get an error, even though the CONTACT has the same ID…

I can't even get either of these formulas to work:

Resource_Name__r.Account.Employer_Number__c = 1
Budget__r.Connected_Relationship__r.Agency__r.Employer_Number__c = 1

Am i entering the formula wrong?

Validation Fail

Best Answer

If you want the validation rule to fire when they are not the same then you want to use:

Resource_Name__r.Account.ScopeTrack_Employer_Number__c != Budget__r.Connected_Relationship__r.Agency__r.ScopeTrack_Employer_Number__c

Validation rules fire when your equation is true.

If this formula expression is true, display the text defined in the Error Message area

Related Topic