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
Shaijan ThomasShaijan Thomas 

TrailHead Challenge is not working correclty

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)

for the above challenge I used following validation rule and its working

IF( AND(NOT( ISBLANK(  MailingPostalCode__c)), NOT(ISBLANK( AccountId )) ),  IF( (NOT(MailingPostalCode__c = Account.ShippingPostalCode__c)), true, false) , false)

But when I click on check challenge giving Error anybody can can help me on this.
   Error Message              "Challenge not yet complete... here's what's wrong: The validation rule failed to enforce the business logic"

Thanks
Shaijan
Best Answer chosen by thisisnotapril
KaranrajKaranraj
Guys..One small request, please guide the developers to resolve the issues if they are facing any problem in understanding the logic or having doubts but please DON'T post the ANSWER of the challenge which is really spoiling the theme of the Trailhead. At the end everyone will look for an answer for the challenges in the forum,they won't try to complete the challenge by own. Guide them to complete but don't post the answer of the challenge here or anywere.

Hope this make sense to all.

All Answers

Jitender  PaddaJitender Padda
It's because your Validation Rule is wrong. Try this one - 
IF (!ISBLANK( AccountId ) && ( MailingPostalCode <> Account.ShippingPostalCode ),true,false)
Shaijan ThomasShaijan Thomas
Not sure what is wrong, @ Jitender @Vickey : its getting same error
Thanks
Shaijan
Shaijan ThomasShaijan Thomas
Hi Vickey
I created it based on above challenge. I create 2 custom text field on Contact (MailingPostalCode__c ) and Account (ShippingPostalCode__c). I created the validation Rule 'Contact_must_be_in_Account_ZIP_Code'. Functionality is working fine with the validation. But when I click on TrailHead check challenge button its giving error. 
Thanks
Shaijan Thomas
Shaijan ThomasShaijan Thomas
@Sanket : please see the above scenario
Shaijan
KaranrajKaranraj
Guys..One small request, please guide the developers to resolve the issues if they are facing any problem in understanding the logic or having doubts but please DON'T post the ANSWER of the challenge which is really spoiling the theme of the Trailhead. At the end everyone will look for an answer for the challenges in the forum,they won't try to complete the challenge by own. Guide them to complete but don't post the answer of the challenge here or anywere.

Hope this make sense to all.
This was selected as the best answer
Shaijan ThomasShaijan Thomas
Thanks Vickey
I thought its custom field, Works fine now
Shaijan ThomasShaijan Thomas
Thanks Sanket, Code is correct
Shiajan
ryg sinryg sin
@Shaijan,

Did you stop receiving the error. I am using the same code as yours and functionality wise its fine but still getting the same  error.