You need to sign in to do that
Don't have an account?
mike franklin 10
Creating Validation Rules - Challenge Question - Validation of Formula
Hello:
I am going through the trailhead in the following area:
Formulas can be created in many different ways. However based on the work instructions, I created the formula as this:
Challenge Exercise Question:
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).
AND(
ISBLANK(MailingPostalCode) = FALSE,
ISBLANK(Account.Name) = FALSE,
Account.ShippingPostalCode <> MailingPostalCode
)
I tested it using the following cases:
Regards,
- Mike
I am going through the trailhead in the following area:
- Admin Intermediate
- Formulas and Validations
- Creating Validation Rules
Formulas can be created in many different ways. However based on the work instructions, I created the formula as this:
Challenge Exercise Question:
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)
AND(
ISBLANK(MailingPostalCode) = FALSE,
ISBLANK(Account.Name) = FALSE,
Account.ShippingPostalCode <> MailingPostalCode
)
I tested it using the following cases:
- Created a contact, linked it to an account (with a postal code), duplicated the postal code value in the required field in the contact object
- The result: The contact record was not allowed to be added and the message error appeared
- Created a contact, did not link it to an account, created the contact and added a postal value in the required field
- The result: The contact record was allowed to be created
Regards,
- Mike
Instead of ISBLANK(Account.Name) = FALSE, check NOT(ISBLANK(Account.Name)). Then you may complete the challenge.
AND(
NOT(ISBLANK(MailingPostalCode)),
NOT(ISBLANK(Account.Name)),
Account.ShippingPostalCode <> MailingPostalCode
)
Thanks,
Dhanya
I am actually getting an error regarding the business logic on both formulas. The error message states that the "The validation rule failed to enforce the business logic."
The business rules that need to be enforced are:
This is what is used in the formula correct? I think the business rules are being enforced correctly, so I do not understand why I can not pass the trail correctly. Am I interpreting the business logic incorrectly?
Regards,
- Mike Franklin
Any help is much appreciated.
AND checks everyline in the formula to be true.
AND (
NOT(ISBLANK(Account.Name)),
NOT(ISBLANK(Account.ShippingPostalCode)),
Account.ShippingPostalCode <> MailingPostalCode
)
If the account is NOT blank AND if the account zip is NOT blank and the Account zip and contact zip are different then call a validation block. Block because the account needs to have a zip and the zip must be the same as the contact or the contact record will not be saved to the related account object.
You can try the below validation rule, it will help you to complete your challenge.
AND(
NOT(ISBLANK(AccountId)),
MailingPostalCode != Account.ShippingPostalCode
)
If you find your Solution then mark this as the best answer.
Thank you!
Regards
Suraj Tripathi
I just wanted to update the info in case anyone else is struggling with this module "Create Validation Rules" currently.
I had to use a mixture of what was listed above and what the module is currently asking for. The validation rule I used to complete the challenge was:
AND(
NOT(IsBlank(AccountId)),
MailingPostalCode <> Account.ShippingPostalCode)
The module recommends using ShippingPostalCode, but I recieved an error message stating that this was mispelled. Only by using Account.ShippingPostalCode did it finally accept the answer. I hope this helps :)
Best,
Garen