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
Darrell JarrettDarrell Jarrett 

creating validation rules error??????

hello all,

i've been working through salesforce trialhead modules and up until the error i came across today i can usually figure out my mistake. i'm on the creating validation rules exercise which is under "formulas & validation" module. i've started over twice and continue to get this same error. can anyone enlighten me on what i'm doing wrong? Here's the 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: REQUIRED_FIELD_MISSING, Required fields are missing: [MailingPostalCode__c, ShippingPostalCode__c]: [MailingPostalCode__c, ShippingPostalCode__c]
Best Answer chosen by Darrell Jarrett
William TranWilliam Tran
Ok,
The MailingPostalCode and ShippingPostatCode are standard fields so you don't need to create custom ones (ending in __c).
Your validation should look something like this:

AND(
NoT(ISBLANK(AccountId)),
MailingPostalCode !=Account.ShippingPostalCode)

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

All Answers

William TranWilliam Tran
 Did you create these fields?

[MailingPostalCode__c, ShippingPostalCode__c]

Can you post a screen print if you did?

Thx
Darrell JarrettDarrell Jarrett
yes those fields were create see below


User-added image









 
William TranWilliam Tran
Can you post your validation rule?  Also, could you provide the link to the trailhead exercise?

Also, based on the error, you must have a trigger, workflow, process builder or something that is doing an insert thus "Insert failed".

You may want to check and disable those first

Thx
Darrell JarrettDarrell Jarrett
Here's the validation rule....
 User-added image
Below is the link for the Trialhead exercise.
https://developer.salesforce.com/trailhead/force_com_dev_beginner/point_click_business_logic/validation_rules

I'm pretty sure there isn't a trigger, workflow or process builder in place doing any type of insert. I was assuming that it's referring to the manuel input of the zipcode data from the screen i entered. that's what didn't make any sense to me. Thanks for all you help
William TranWilliam Tran
Ok,
The MailingPostalCode and ShippingPostatCode are standard fields so you don't need to create custom ones (ending in __c).
Your validation should look something like this:

AND(
NoT(ISBLANK(AccountId)),
MailingPostalCode !=Account.ShippingPostalCode)

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
This was selected as the best answer
Darrell JarrettDarrell Jarrett
Thanks William that worked perfectly. I really appriciate all of your help.