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
Christian Belko 12Christian Belko 12 

Assessment not confirming Validation Rule

I'm on the final part of the Formulas & Validations Badge, and have confirmed that my validation rule is working correctly. When I test my validation formula for the assignment, it works fine. Here's the rule I'm using.

AND( 
NOT(ISBLANK(AccountId)), 
MailingPostalCode <> Account.ShippingPostalCode 
)

The assignment is to create a contact with a MailingPostalCode that has an account and does not match the associated Account ShippingPostalCode should return with a validation error and not be inserted. It also should apply to contact records with an associated account. Contact records with no associated parent account can be added with any MailingPostalCode value. 

I believe this is setup as needed, but the error its throwing is my validation rule saying that an insert failed because of the rule? Any ideas on how to fix this?
Peter van der Meij | StepOrangePeter van der Meij | StepOrange
So the account id should not be blank,

and the address should match the account shipping address?

keep in mind that validation rules work the other way arround. when the result is true, they give an error.
so i think the validation rule should be:

ISBLANK(AccountId) && MailingPostalCode <> Account.ShippingPostalCode



 
William TranWilliam Tran
You likely have a trigger or workflow/process builder causing the insert to fail.

The validation looks fine and CANNOT cause the insert to fail, it can prevent the insert action but CANNOT cause it to fail.

As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you. 

Thanks
Jayson Faderanga 14Jayson Faderanga 14
Hi Christian,

The validation is good. If you're doing the below scenario, the validation is expected to fire.
1. You're creating a new contact record  (insert) and you populate the account lookup field wherein it matches the mailing postal code of the contact
2. You're referencing a different Account Lookup on Contact, maybe a custom lookup field