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
Nancy Engel 2Nancy Engel 2 

Issue with the Validation Rule Trailhead module

Here is my version of the Trailhead Valication Rule:

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

I tried it out and it works fine (checked syntax and also tried to create a contact with a different zip than the account and got the error, corrected the zip and the contact was saved).  But I get this error in Trailhead.

"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, Contacts associated with an Account must have the same Mailing Postal Code as the Account Shipping Postal Code: [MailingPostalCode]"

Am I blind and missing something?????
Best Answer chosen by Nancy Engel 2
Sandeep BhanotSandeep Bhanot
Nancy - we strongly recommend that you use a fresh new DE Org to try Trailhead challenges since pre-existing code/config in an Org can sometimes trip up the challenges. Sounds like that might be what's going on in this case (given the existence of the Non-Profit package) and so can you please attempt the challenge in a new DE Org.
You can continue to use the current credentials to login to Trailhead and track your points/badges (so that you don't lose anything that you've already completed). Just login to a fresh new DE Org to attempt the acutal challenges. Hope this helps.

Sandeep Bhanot
Salesforce.com

All Answers

Shaijan ThomasShaijan Thomas
Inactivate all the validation and workflows in you objects.
IF( AND(!ISBLANK( AccountId), MailingPostalCode != Account.ShippingPostalCode ), true, false)
try this
If its useful make best answer
Shaijan Thomas
Nancy Engel 2Nancy Engel 2
Still getting the error.  Changed your formula to be <> instead of != and still get the same error.  Any one else have a recommendation?  Like I said, I tested it and it works, just won't pass the Trailhead confirmation test.  When I put a contact in with a different zip than the account its associated with, I get my error.  When I correct the zip, I can save the contact.  So it works, just won't be approved by the Trailhead program.  Thanks for any help!
Nancy Engel 2Nancy Engel 2
I wonder if this can be a Non-Profit Starter Pack issue?  I have the NPSP installed in my Dev org.  So I can create a contact without an account, but when the contact is saved, a Household account is made, which carries the address from the contact over to the account.  The account is more or less hidden and only the contact can be seen.  Maybe this is causing an issue???
Sandeep BhanotSandeep Bhanot
Nancy - we strongly recommend that you use a fresh new DE Org to try Trailhead challenges since pre-existing code/config in an Org can sometimes trip up the challenges. Sounds like that might be what's going on in this case (given the existence of the Non-Profit package) and so can you please attempt the challenge in a new DE Org.
You can continue to use the current credentials to login to Trailhead and track your points/badges (so that you don't lose anything that you've already completed). Just login to a fresh new DE Org to attempt the acutal challenges. Hope this helps.

Sandeep Bhanot
Salesforce.com
This was selected as the best answer
Nancy Engel 2Nancy Engel 2
A fresh Dev org solved the problem.  Thanks!  Must have cobwebs in the corners of my other dev orgs!
Beth van ElswykBeth van Elswyk
Thank you I was having issues with figuring this one out as well.
Michael KonykMichael Konyk
Thanks Shaijan Tomas, it worked for me!
Kenneth CloutmanKenneth Cloutman
Just a comment on Shaijans solution.

the if() is completely unnecessary.  the if() is basically testing a condition, and when the condition is true, it returns true.  It would be much cleaner to return the result the condtion itself, i.e., the validation rule would simply be:

AND(!ISBLANK( AccountId), MailingPostalCode != Account.ShippingPostalCode )