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
Bill Hare 19Bill Hare 19 

validation rule trailhead issue

Anyone Seen this on the validation rule trailhead? - 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: []
Jagan ReddyJagan Reddy
have you write any validation rule for this one. 
Yogesh KulkarniYogesh Kulkarni
Hi Bill,

Check all the active validation rules and triggers to trace down the error throwing statement / rule.

Thanks,
Yogesh
Jitender  PaddaJitender Padda
I believe you have a Validation Rule or Trigger on Contact which is causing the FIELD_CUSTOM_VALIDATION_EXCEPTION.
Chen NavonChen Navon
Hi Bill. please write the validation rule that you wrote- I'll might be able to help you with that
Joe Gold 9Joe Gold 9
I am also having trouble with the validation rules trailhead. This is the validation rule I am using, but it is not working.
and (not(isblank( MailingPostalCode )),
          not (isblank(Account.Id )),
          MailingPostalCode<>Account.ShippingPostalCode
                                                                                             )
Not sure where I'm going wrong.
Chen NavonChen Navon

Hi Joe. 

First, the first line ("not(isblank( MailingPostalCode )") can make an issue; what if the account's postal code field is empty, and so does the contact's mailing field? in this case- this expression will return 'false' instead of 'true'.
Second, the <> operator. Try to use = operator.
It should not be that way, I know, and I sent feedback for this matter.

Try to use the next rule (it worked for me):

AND( 
NOT(ISBLANK( Account.Name )), 
MailingPostalCode__c = Account.ShippingPostalCode__c 
)
Bill Hare 19Bill Hare 19
I have been away from this due to work - just got laid off - so here is my validation rule

Account.ShippingPostalCode  <>  MailingPostalCode
Joaquin Peña FernandezJoaquin Peña Fernandez
Hello Chen,
I did the formula:

NOT(ISBLANK( Account.Id )) && MailingPostalCode__c = Account.ShippingPostalCode__c 

and the formula worked, but the exercise was not validated properly. I enter with the AND and it was validated

thanks
Fayyaz MianFayyaz Mian
NOT( ISBLANK( AccountId )) 
&& 
( MailingPostalCode <> Account.ShippingPostalCode )
Deb_GearsCRMDeb_GearsCRM
Same issue in the Trailhead challenge.  I have 
and(
not(isblank(AccountId)),
MailingPostalCode<>Account.ShippingPostalCode)

and it says it was not correct. 
Holger Dehne (HDE)Holger Dehne (HDE)
same for me.

i repeat the trails with a different trailhead account. i did pass the challenge with my old account earlier this year but now, with the same rule in the same org, i keep getting the same error over and over again. is someone able to say if this challenge is somehow blocked by another trail? i completed a lot of trails in my DE org so it might be possible that there is a conflict, but i have no idea where to start searching for it.

 
Manikanta DonthuManikanta Donthu
I pass this Trail with this formula.

AND(NOT(ISBLANK(Account.Name)), MailingPostalCode <> Account.PostalCde)
Deb_GearsCRMDeb_GearsCRM
If you are sure your validation rule works when you create a new contact with a different zip code and still get the 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: []

Then create a new Dev Org and try again.  I just did this and passed with:

AND( 
NOT(ISBLANK(Account.Id)), 
MailingPostalCode != Account.ShippingPostalCode 
)
Marc e. SwanMarc e. Swan

I just passed the same challenge with

AND( 
NOT(ISBLANK(Account.Id)), 
MailingPostalCode != Account.ShippingPostalCode 
)
Krasi IvanovKrasi Ivanov
Just passed the challenge with:

AND( 
NOT(ISBLANK(Account.Name)), 
MailingPostalCode <> Account.ShippingPostalCode 
)
Siva Krishna PrabhalaSiva Krishna Prabhala
Just passed the challenge with:

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

Ok, I agree, those formulas work for this challenge.

But if we test the situation where the contact has no account linked. If he write a postal code, I think it won't work because he won't complete the first condition "NOT(ISBLANK(Account.Name))".
Wouldn't that be more appropriate to write this formula instead to include this case ?
OR(
    AND(
        NOT(ISBLANK(Account.Name)), //If the contact is linked with an account...
        MailingPostalCode <> Account.ShippingPostalCode//... he has to have a different postal code
    ),
    ISBLANK(Account.Name)//but the case of contact without account is OK too
)

Am I right ?

Suraj Tripathi 47Suraj Tripathi 47
Hi Bill Hare 19,
 
AND(
NOT(ISBLANK(AccountId)),
MailingPostalCode != Account.ShippingPostalCode
)

If you find your Solution then mark this as the best answer. 

Thank you!

Regards 
Suraj Tripathi