• Md Dilowar Hussain
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
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 0013600000LcVd3AAF; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Cannot delete account with related opportunities.: []

Go this error while working on the first challenge under Apex Triggers in Developer Beginner Trailhead.

Create an Apex trigger for Account that matches Shipping Address Postal Code with Billing Address Postal Code based on a custom field.

And my solution for the same is as follows:

trigger AccountAddressTrigger on Account (before insert, before update){
    
    for (Account a : Trigger.new) {
        if(a.BillingPostalCode != null && a.Match_Billing_Address__c == true){
            a.ShippingPostalCode = a.BillingPostalCode;
        }
    }


}

 
I am working in https://developer.salesforce.com/trailhead/point_click_business_logic/validation_rules.I have following message in validate rule:"Challenge Not yet complete... here's what's wrong: 
The validation rule failed to enforce the business logic"
My examples:
1.NOT(ISBLANK(AccountId)) && Account.ShippingPostalCode != MailingPostalCode
2.AND( NOT(ISBLANK(AccountId)),
 MailingPostalCode != Account.ShippingPostalCode
 )
3.AND( NOT(ISBLANK(AccountId)),
 MailingPostalCode <> Account.ShippingPostalCode
 )
Help me please solve this problem!
i'm getting below error for one of the challenge in trailhead. 

 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: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Contact_must_be_in_Account_ZIP_Code: []


CHALLENGE:
Create a validation rule to check that a contact is in the zip code of its account.
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 i used below formula in validation Rule: 
 
AND(ISBLANK( Account.Name ),  MailingPostalCode <>  Account.ShippingPostalCode )