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
Kevin Breazile 1Kevin Breazile 1 

Trouble with Creating Validation Rules Challenge

I have a problem when I created the Validation Rule for the "Creating Validation Rules" Challenge.  I used the following validation rule on the Contact Object:
AND(
NOT(ISBLANK(Account.AccountNumber)),
MailingPostalCode<>Account.ShippingPostalCode)

This works when I test it.  When there is no account, it creates the contact.  When there is an Account associated with the Contact, it prepopulates the Mailing Postal Code with the Billing Zip Code (not the shipping zip code).  If I change it, to match the Shipping Zip Code, I can create the Contact.  If the Zip Code doesn't match then I recieve the message I created saying:  "Contact Mailing Zip Code must match Account Shipping Zip Code".  This seems to be what the challenge is asking.

What could I be doing wrong?  Or is this a problem with the logic for the Challenge?

Kevin

Kev 
Best Answer chosen by Kevin Breazile 1
geeta garggeeta garg
AND( NOT(ISBLANK( AccountId )) ,MailingPostalCode <> Account.ShippingPostalCode)



you can use it in Error Condition Formula.

All Answers

Kevin Breazile 1Kevin Breazile 1
Ok.  I don't know why the first validation rule didn't work for the Challenge, but when I changed the first part of the formula from:
NOT(ISBLANK(Account.AccountNumber))
to
NOT(ISBLANK(Accountid))  
it worked.

Kev
William TranWilliam Tran
Checking on the AccountId is the proper way.

Checking on Account.AccountNumber can be problematic since you are reference an Account Number on the Account object that may not exist (or is null).  Programmatically, this often gives you the "null pointer reference" exception message.

As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

Thanks
geeta garggeeta garg
AND( NOT(ISBLANK( AccountId )) ,MailingPostalCode <> Account.ShippingPostalCode)



you can use it in Error Condition Formula.
This was selected as the best answer
Roswell TanRoswell Tan
I receive an error and am told AccountId field does not exist. What's up with that?
geeta garggeeta garg
Hi Roswell,
Can you tell me on which object did you apply?
Becoz It is applicable on contact object.
Plz attach the screenshot.
 
Roswell TanRoswell Tan
Geeta,

I was able to get the syntax correct when creating the validation rule on the Contact object. However, I am receiving an error in the assignment. Attached is the screenshot. Could you please tell me what I'm missing? Thanks!User-added image
geeta garggeeta garg
Hi Roswell,

Before checking this challenge, please deactive all the validation rule, and trigger.
I think that other validation rule and trigger is creating problem for checking.
I think that you made shippingPostalCode field in account. But it is already in account so there is no need to make. please don't use custom field in this challenge.

Thanks,