Ask Search:
Adeline MooreAdeline Moore 

Please help! Trying to complete this challenge:Create a validation rule to check that a contact is in the zip code of its account

Here is the error message I keep getting:
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, A contact with a MailingPostalCode that has an account and does not match: []
Here is my screen shot of my validation rule:
User-added image
Best Answer chosen by Adeline Moore
Sandeep Kumar GaddamSandeep Kumar Gaddam
Hello Moore,

try below formula in validation this should fire when you try to save contact which has diffrent zipcode then the account it is belong to . 
 
ISBLANK(AccountId)||(MailingPostalCode<>Account.ShippingPostalCode)

Also when are you getting this error ? System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, A contact with a MailingPostalCode that has an account and does not match: []

Are you getting this at the time of inserting contact from dataloader ? if so please have the data which will sastify the validation rule.

Thanks
PS: Mark a best answer as well so that thread is closed and help us to keep community clean.
 

All Answers

Sandeep Kumar GaddamSandeep Kumar Gaddam
Hello Moore,

try below formula in validation this should fire when you try to save contact which has diffrent zipcode then the account it is belong to . 
 
ISBLANK(AccountId)||(MailingPostalCode<>Account.ShippingPostalCode)

Also when are you getting this error ? System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, A contact with a MailingPostalCode that has an account and does not match: []

Are you getting this at the time of inserting contact from dataloader ? if so please have the data which will sastify the validation rule.

Thanks
PS: Mark a best answer as well so that thread is closed and help us to keep community clean.
 
This was selected as the best answer
Adeline MooreAdeline Moore
Thank you for your answer. I tried every Code I could and it turned out. I had to start a new Developer account then run the same exact code and it finally worked :)
Jason StengrenJason Stengren
I was getting the same validation error and after thinking some more through the logic, this fixed it: NOT ISBLANK(AccountId)&&(MailingPostalCode<>Account.ShippingPostalCode)
Pralhad ArgadePralhad Argade
@Jason Stengren Thanks for your formula. 

 
Sombir SheoranSombir Sheoran
Hi Jason,

Code "​NOT ISBLANK(AccountId)&&(MailingPostalCode<>Account.ShippingPostalCode)" worked for me.
I was also getting the same error. 

I was getting errors till used '​ISBLANK(AccountId)||(MailingPostalCode<>Account.ShippingPostalCode)'

As soon as i changed validation to NOT ISBLANK(AccountId)&&(MailingPostalCode<>Account.ShippingPostalCode) it worked.

Thanks.
Sibeesh KumarSibeesh Kumar
Hi Jason & Sombir

I was also getting the same error. 
"​NOT ISBLANK(AccountId)&&(MailingPostalCode<>Account.ShippingPostalCode)" worked for me.


Thanks.