You need to sign in to do that
Don't have an account?

Error generated during Trailhead Challenge
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;
}
}
}
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;
}
}
}
Please check you any trigger you have on Account object which is creating opportunity ? If yes then please deactivate the trigger and try again.
Please try to activate all other trigger and validation and try again
Let us know if that will help you
All Answers
Please check you any trigger you have on Account object which is creating opportunity ? If yes then please deactivate the trigger and try again.
Please try to activate all other trigger and validation and try again
Let us know if that will help you
I have created a custom checkbox field as "Match Billing Address" with the API name, "Match_Billing_Address__c". Below shows the screen shot.
Below is my code in DEV console.
trigger AccountAddressTrigger on Account (before insert, before update) {
for(Account a : Trigger.new){
if(a.Match_Billing_Address__c){
a.ShippingPostalCode = a.BillingPostalCode;
}
}
}
But the below error message is getting displaying while checking the challange.
Challenge Not yet complete... here's what's wrong:
A field with an API Name 'Match_Billing_Address__c' does not exist on the Account object.
Request your suggestions to get rid of the same.
Please create field on account object
I am able to find the mistake out. It's working now. Thanks. :):)