How to create a validation rule to check that a contact is in the zip code of its account?

255    Asked by AashnaSaito in Salesforce , Asked on Apr 26, 2023

 I think i misunderstood validation rules, so i answered the following challenge creating a validation rule that only applies if the insertion is different for what i write in the rule:


AND(ISBLANK( Account.Id ),

OR( MailingPostalCode = Account.ShippingPostalCode ))

I mean, if the insertion/update is correct, then do it, else display an error message.


The challenge has succeeded.

My question is, am i wrong or i should write in the validation rule the conditions where shouldn't be accepted?

Here is the challenge

To create a validation rule to check that a contact is in the zip code of its account - According to the challenge

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 saved.

The validation rule should ONLY apply to contact records with an associated account. Contact records with no associated parent account can be added with any MailingPostalCode value. (Hint: you can use the ISBLANK function for this check)

the correct approach will be as follows:
AND(NOT(ISBLANK(Account.Id))
, NOT(ISBLANK(MailingPostalCode))
, NOT(ISBLANK(Account.ShippingPostalCode))
, (MailingPostalCode != Account.ShippingPostalCode)
)

Since, you need to check all the blank entries for Account's Id, ShippingPostalCode and Contact's MailingPostalCode and then validate if Contact's MailingPostalCode != Account.ShippingPostalCode



Your Answer

Interviews

Parent Categories