You need to sign in to do that
Don't have an account?
Validation Rule Challenge :The validation rule failed to enforce the business logic
This challenge seems simple enough but I'm stuck and any help would be appreciated.
So the Challenge is Create a validation rule to check that a contact is in the zip code of its account. here is the question below:
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 (hint: you can use the ISBLANK function for this check) can be added with any MailingPostalCode value
Here is my work.. Any help would be appreciated.. thanks,
Rule Name Contact_must_be_in_Account_ZIP_Code Active [Checked]
Error Condition Formula AND( BillingPostalCode = ShippingPostalCode )
Error Message Billing zipcode does not match the Shipping Zipcode Error Location Billing Zip/Postal Code
So the Challenge is Create a validation rule to check that a contact is in the zip code of its account. here is the question below:
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 (hint: you can use the ISBLANK function for this check) can be added with any MailingPostalCode value
Here is my work.. Any help would be appreciated.. thanks,
Rule Name Contact_must_be_in_Account_ZIP_Code Active [Checked]
Error Condition Formula AND( BillingPostalCode = ShippingPostalCode )
Error Message Billing zipcode does not match the Shipping Zipcode Error Location Billing Zip/Postal Code
I can't see your formula code.
Never mind, because you've used an "AND", your formula should have 2 conditions:
- 1st one have to verify if "AccoundId" is populated (The validation rule should ONLY apply to contact records with an associated account).
- 2nd one have to verify the equality between "MailingPostalCode" and "Account.ShippingPostalCode".
Your condition should looks like this: Hope this helps,
Fred
All Answers
I can't see your formula code.
Never mind, because you've used an "AND", your formula should have 2 conditions:
- 1st one have to verify if "AccoundId" is populated (The validation rule should ONLY apply to contact records with an associated account).
- 2nd one have to verify the equality between "MailingPostalCode" and "Account.ShippingPostalCode".
Your condition should looks like this: Hope this helps,
Fred
I also received the same issue but my Error condition was as following:
NOT( ISBLANK( AccountId ) )
&&
MailingPostalCode <> Account.ShippingPostalCode
What is the difference between the error condition you mentioned and the one i used ? I am also using && expression between both my conditions.. ?
Not sure but I think the formula can only contain one expression.
So, if you have a combined condition, you have to write something like that: Hope this helps,
Fred
One of the simplest solution is:
AND( ISNEW() , AccountId <> null, MailingPostalCode <> Account.ShippingPostalCode )
It's working fine for this Challenge with below code
Thanks & Regards,
Satya P
This was so complicated. Anytime i tried to put in the MailingPostalCode it said it didnt exist. Any time i tried to put the account. before anything it said it didnt exist. I finally just wrote it myself.
AND(( BillingPostalCode <> ShippingPostalCode),
NOT(ISBLANK(ShippingPostalCode)))
And it worked perfectly, Challenge Accepted it
Error :
Challenge not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Delete failed. First exception on row 0 with id 0032400000IrrmOAAR; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, MadMimi.onDeleteContact: execution of BeforeDelete caused by: System.NullPointerException: Argument cannot be null. (System Code) : []
Replace "Account.Id" by "AccountId" (remove the dot) as you must refer to the Contact's field.
It should be ok.
Regards,
Fred
Even if I change the field "Account.Id" with "AccountId", the same error appears.
AND(
NOT( ISBLANK( AccountId ) ),
MailingPostalCode <> Account.ShippingPostalCode
)
Error message- 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, Mailing and Shipping postal code don't match: [AccountId]
Here's how I got passed this:
Turn on logging and focus on the last test run.
MailingPostalCode needs to be something.
I found it using the debug log as you can see here in case you get the same message:
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, error please enter appropriate zip code: [OtherPostalCode]
help me in this
AND(ISNEW(),NOT(ISBLANK(Account.Id)),NOT(ISBLANK(MailingPostalCode)), MailingPostalCode<> Account.ShippingPostalCode)
Although this
However it worked for me when I gave the below formula.
AND(NOT(ISBLANK(Account.Id)),MailingPostalCode<> Account.ShippingPostalCode)
AND(NOT(ISBLANK(AccountId)),MailingPostalCode<> Account.ShippingPostalCode)
NOT(ISBLANK(AccountId)) &&
MailingPostalCode<>Account.ShippingPostalCode
The validation rule does not reference the account Shipping Postal Code field (ShippingPostalCode)'
using this code:
AND(NOT(ISBLANK(Account.Id)),MailingPostalCode<> Account.ShippingPostalCode)
I thought that 'account.ShippingPostalCode' references this?
AND(MailingPostalCode <> Account.ShippingPostalCode, NOT(ISBLANK( Account.Name )))
The validation rule failed to enforce the business logic";
I have created this Validation Rule under Standard "Account" Object.
Could someone help me on this, where i did the mistake or have to create this rule in any other specific object?
Advance Thanks!
This works perfectly fine.
AND(
BillingPostalCode <> ShippingPostalCode,
NOT(ISBLANK( Name ))
)
I tried many ways. But no difference in error : Challenge Not yet complete... here's what's wrong:
A contact with no parent account could not be inserted. The validation rule should only apply to contact records with an associated account.
I tried every suggesstion on this feed and nothing worked. Do you think I have some settings on that dont allow the business logic to execute?
(ISBLANK(Account.Id))
||
AND(
NOT( ISBLANK( AccountId ) ) ,
NOT(ISBLANK( MailingPostalCode )),
(MailingPostalCode <> Account.ShippingPostalCode)
)
Thanks in advance for your help
Paul O. had the solution which worked for me,
AND(
NOT(ISBLANK(AccountId)),
NOT(ISBLANK(Account.ShippingPostalCode)),
MailingPostalCode<>Account.ShippingPostalCode
)
But I tried other solutions on this and other advice pages which failed, such as:
AND(NOT(ISBLANK(Account.Id)),MailingPostalCode<> Account.ShippingPostalCode)
and variations such as:
AND(NOT(ISBLANK(Account.ShippingPostalCode)),MailingPostalCode<> Account.ShippingPostalCode)
It seems to me that both of these should work --??
IF( AND(MailingPostalCode <> Account.ShippingPostalCode, ISBLANK( Account.ShippingPostalCode ) ),False, True)
Alos used the insert buttons to avoid small typo's.
At any rate, I am able to add and edit contacts with correct blocking only when I have both an account and mailing address, and their postal codes don't match. But, trailhead tells me that "The validation rule failed to enforce the business logic".
So, I changed to the logic given in Paul Osnes' answer, and it works the same in real life, but now the challenge passes too. I suppose that means that the challenge is looking for what it thinks is the right answer, not actually testing that the logic works? Sorry to tag a question onto another - it's really more for benefit of others in my boat, though I'd be able for confirmation that this is what is going on.
Challenge Not yet complete... here's what's wrong:
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: REQUIRED_FIELD_MISSING, Required fields are missing: [Start__c, Property__c]: [Start__c, Property__c]
I need help fast please.
Error Condition Formula:
AND(
NOT( ISBLANK( AccountId ) ),
MailingPostalCode <> Account.ShippingPostalCode
)
I am getting below error:
Challenge Not yet complete... here's what's wrong:
The validation rule failed to enforce the business logic
Challenge Not yet complete... here's what's wrong:
The validation rule was not found. Make sure that you created a Validation rule with the name 'Contact must be in Account ZIP Code'
AND(
NOT(ISBLANK(AccountId)),
MailingPostalCode != Account.ShippingPostalCode
)
AND(
NOT(ISBLANK(AccountId)),
MailingPostalCode != Account.ShippingPostalCode
)
AND(
NOT( ISBLANK( AccountId ) ),
MailingPostalCode <> Account.ShippingPostalCode
Try to do the same process in different Trial head playground if you are facing hte same issue.
You will pass the exam with not error.
P.S- I alson faced the same issue.
I have a problem with this ...can any one help me...???
·
I have created the rule both in Account and Contact, I delete the rule in the Account and it worked.
AND(( BillingPostalCode <> ShippingPostalCode),
NOT(ISBLANK(ShippingPostalCode)))