+ Start a Discussion
Erin JodatErin Jodat 

Validation Rule - Trailhead

Arg, I've read other posts about this but it will not work for me! The validation rule in 'Formulas & Validations' is: 
To complete this challenge, add a validation rule which will block the insertion of a contact if the contact is related to an account and has a mailing postal code (which has the API Name MailingPostalCode) different from the account's shipping postal code (which has the API Name ShippingPostalCode).Name the validation rule 'Contact must be in Account ZIP Code'.
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.
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)

My rule is: 
AND(
NOT( ISBLANK( AccountId )),
Contact.MailingPostalCode <>   Account.ShippingPostalCode
)

But it comes back with 'The validation rule failed to enforce the business logic.'

Not sure what I'm missing.....
Amit Khanduri.Amit Khanduri.
Try It with this surely help..

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

Thanks,
Amit
Erin JodatErin Jodat
Thanks Amit, but it won't let me save this rule as it says "Error: Field MailingPostalCode does not exisit. Check Spelling" 
Vivek DeshmaneVivek Deshmane
Hi,
You can try below one. 
AND(
NOT( ISBLANK( AccountId )),
MailingPostalCode <>   Account.ShippingPostalCode
)

Please let me know if this works.
Best Regards,
-Vivek
Himanshu ParasharHimanshu Parashar
Hi Erin,

Validation rule is looking good, can you make sure following things

1. You are writing MailingPostalCode instead of Contact.MailingPostalCode in rule
2. You have named rule as Contact_must_be_in_Account_ZIP_Code
3. it is active.

Thanks,
Himanshu
Amit Khanduri.Amit Khanduri.
Please go through your feilds again and make sure all setup correct as mentioned in challenge.
Let me know 
Erin JodatErin Jodat
It tells me MailingPostalCode does not exist! So frustrated...
Himanshu ParasharHimanshu Parashar
can you post screenshot of validation rule ?
Erin JodatErin Jodat
Ha I got it! Thanks for all your help!!! Love this community :)