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
NAVEEN KUMARNAVEEN KUMAR 

Having issue in trailhead challenge under Formulas & Validations task.

i'm getting below error for one of the challenge in trailhead. 

 ERROR:

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, Contact_must_be_in_Account_ZIP_Code: []


CHALLENGE:
Create a validation rule to check that a contact is in the zip code of its account.
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)


And i used below formula in validation Rule: 
 
AND(ISBLANK( Account.Name ),  MailingPostalCode <>  Account.ShippingPostalCode )
 
Best Answer chosen by NAVEEN KUMAR
Sai Ram ASai Ram A
Hello Naveen
!ISBLANK( AccountId ) && ( MailingPostalCode <> Account.ShippingPostalCode )

P.S. If this answers you question, please mark it as "Best Answer" so it will help other community members too.

Thank you
BLearn

All Answers

Sai Ram ASai Ram A
Hello Naveen
!ISBLANK( AccountId ) && ( MailingPostalCode <> Account.ShippingPostalCode )

P.S. If this answers you question, please mark it as "Best Answer" so it will help other community members too.

Thank you
BLearn
This was selected as the best answer
NAVEEN KUMARNAVEEN KUMAR
Thanks BLearn. :-)
Jean-BaptisteJean-Baptiste
Hi,

Thanks for sharing the solution Sai Ram A! Actually I came up with the same idea as Naveen when taking the trail myself:
AND(ISBLANK( Account.Name ),  MailingPostalCode <>  Account.ShippingPostalCode )

Does someone understand why it's not working? Thanks.
greg ernstgreg ernst
Naveen, and Jean-Baptiste,

I had a slightly different formula and got the same error. You formula is valid and should not throw an exception, in my opinion. Not sure if this a bug with the Trailhead validation query or SF itself.

In searching for other hits on this error, they are all in regards to APEX test coverage code.

So it seems the original question has not really been answered...

Having said that the formula posted above by Sai Ram does allow the Challenge to complete.

Greg
Md Dilowar HussainMd Dilowar Hussain
Thanks Sai Ram.

Validation rule, !ISBLANK( AccountId ) && ( MailingPostalCode <> Account.ShippingPostalCode ) has worked in my case.