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
Matt Low 2Matt Low 2 

Challenge - Formulas & Validations/Creating Validation Rules

Hello - I'm working on the challenge for Creating Validation Rules and when I check my challenge, I'm getting a message, "Challenge not yet complete... here's what's wrong: The validation rule failed to enforce the business logic". I can actually see that my validation rule message is being applied when I'm in an account and trying to create a related contact with a Mailing Postal Code different from the account's Shipping Postal Code. I can also successfully create a contact with no associated parent. I've attached a screenshot of the message generated as a result of my validation rule being applied. Does Trailhead ever report a failed challenge, even though it was developed correctly? Thanks in advance.

MattUser-added image 

 
Best Answer chosen by Matt Low 2
Ganesh HembramGanesh Hembram
Hi Matt,

You can use below Formula as well.

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

Hope this helps too.

All Answers

Ganesh HembramGanesh Hembram
Hi Matt,

Can you please post your Validation Rule's Error Condition Formula ?
Shyama B SShyama B S
Hi Matt,
This is how mine looks like and it worked.
User-added image

Please let me know if this helped.
Thanks.
Matt Low 2Matt Low 2
In Contact I have:   MailingPostalCode__c  <> Account.ShippingPostalCode__c  &&   NOT(ISBLANK(AccountId )). Please see attached screenshot. Thanks.

MattUser-added image
Ganesh HembramGanesh Hembram
Hi Matt,

You can use below Formula as well.

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

Hope this helps too.
This was selected as the best answer
Matt Low 2Matt Low 2
Thanks Ganesh. That worked. It appears that I can use the names 
'Account.ShippingPostalCode' and  'MailingPostalCode' versus the API names ('MailingPostalCode__c' and 'Account.ShippingPostalCode__c'). I don't really see how that works since my label names have spaces (e.g. 'Mailing Postal Code'). Underneath, how does it know what 'MailingPostalCode' is? Thanks again.
NityaUdayaBhanu VissapragadaNityaUdayaBhanu Vissapragada
can any one please help me

Error:
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: [MailingPostalCode]
 
Formula:
OR((MailingPostalCode <> Account.ShippingPostalCode ) ,(NOT(ISBLANK(AccountId ))))

I ave tried te above formla also didnt work
Meric AsanerMeric Asaner
Date: November 15th 2021
Trail: Formulas and Validations --> Create Validation Rules
Error: Field MailingPostalCode does not exist. Check spelling.

Solution: Instead of writing MailingPostalCode try writing BillingPostalCode