You need to sign in to do that
Don't have an account?
Dan Broussard
Validation rules for Trailhead Quiz
I am working on a Trailhead Quiz for Formulas & Validations Creating Validation Rules
https://developer.salesforce.com/trailhead/point_click_business_logic/validation_rules
The quiz wants to validate a zip code rule for a contact to match zip code with account UNLESS this a a contact with no account associated.
Error from Trailhead that I receive is: The validation rule failed to enforce the business logic.
My "logic" was that if accountid in contact is blank there is no account associated ; if not blank check against account zip. A blank accountid is a NOTTRUE result for the first condition and the second condition is null. An accountid is NOT blank, a TRUE and second condition would be testd.
My validation code is:
AND (
NOT(ISBLANK( AccountId )),
(MailingPostalCode <> Account.ShippingPostalCode)
Any help is appreciated. I am used to the more classical (IF( TRUE) AND IF (TRUE)) ELSE....format.
Thank You!
https://developer.salesforce.com/trailhead/point_click_business_logic/validation_rules
The quiz wants to validate a zip code rule for a contact to match zip code with account UNLESS this a a contact with no account associated.
Error from Trailhead that I receive is: The validation rule failed to enforce the business logic.
My "logic" was that if accountid in contact is blank there is no account associated ; if not blank check against account zip. A blank accountid is a NOTTRUE result for the first condition and the second condition is null. An accountid is NOT blank, a TRUE and second condition would be testd.
My validation code is:
AND (
NOT(ISBLANK( AccountId )),
(MailingPostalCode <> Account.ShippingPostalCode)
Any help is appreciated. I am used to the more classical (IF( TRUE) AND IF (TRUE)) ELSE....format.
Thank You!
Please try below validation rule. I got all 500 Point with below validation rule Please mark this as solution is this will help you
Thanks
Amit Chaudhary
amit.salesforce21@gmail.com
All Answers
AND (
NOT(ISBLANK( AccountId )),
(MailingPostalCode <> Account.ShippingPostalCode))
Please try below validation rule. I got all 500 Point with below validation rule Please mark this as solution is this will help you
Thanks
Amit Chaudhary
amit.salesforce21@gmail.com
Thank you all for taking the time to help me with this puzzle.
I tried all of your answers and I still received the same error. I did turn activate on and off to see if that would generate a different error. Same error message. I also used the insert field pull down which added the _c to field names; that generated same error when I used all of your and my code. I believe that all of our code is correct, all pased syntax checks and seem true logic to me. I just do not know what answer the quiz wants.
If any ideas come to mind, please let me know. It has got to be something I am doing that is really simple and dumb!
I rebooted my system, went back to SFDC, went back to the quiz, and it passed!
Go figure!
Thanks guys...
I was going nuts...I had all the right fields; my syntax just sucked. Thanks for the correction.
I've seen:
and:
The formula expression dropdown lists it as:
Not sure if Salesforce will care about that or not...but if you're running into problems that's a place to check!
I tested it by setting up a new contact and and the test confirmed that it is not matching the business case. The rule I used was:
AND(
NOT(ISBLANK(Account.Name)),
NOT(MailingPostalCode__c <> Account.ShippingPostalCode__c)
)
My previous attempt of the validation, successfully passed my test of the business case but failed Trailheads challenge. That rule was
AND(
NOT(ISBLANK(Account.Name)),
(MailingPostalCode__c <> Account.ShippingPostalCode__c)
)
Any feedback welcome.
ISBLANK(Account.Name) II ((MailingPostalCode__c <> Account.ShippingPostalCode__c)
work equally well?
I.e. if the account.Name is blank, then a contact isn't tied to an account, so MailingPostalCode can be anything. Alternately, any case where the two postal codes match works.
There is some kind of bug here, since it isn't consistently displaying Account.PostalCode fields in my system. They show up when you do Add Field, but they don't show up if you open up Accounts and look at the list of fields there.
It isn't what the challenge is looking for, but is there any case where it wouldn't produce the same outcome?
AND(
NOT( ISBLANK( Account.Id ) ),
Account.ShippingPostalCode__c = MailingPostalCode__c
)
Here is how I translate that into English:
If all the following are true, return a validation error:
1. The account Id of the contact is not blank
AND
2. The account Shipping Postal Code matches the Contact Mailing Postal Code.
The challange states that the Account shipping postal code and Contact Miling Postal code should not match to return a validation error. So I passed, but with what I think is incorrect business logic. On the upside, having to sort through that problem made me learn more about writing formulas than I've ever tried to before. So Trailhead still rocks!
2NOT(ISBLANK(AccountId)),
3MailingPostalCode != Account.ShippingPostalCode
4)
(( Account.ShippingPostalCode <> MailingPostalCode ) && NOT(ISBLANK( AccountId )))