You need to sign in to do that
Don't have an account?
Hi I am stuck with an error shown in below while completing the trailhead on Apex Trigger - Get Started with Apex.
"For this challenge, you need to create a trigger that, before insert or update, checks for a checkbox, and if the checkbox field is true, sets the Shipping Postal Code (whose API name is ShippingPostalCode) to be the same as the Billing Postal Code (BillingPostalCode)".
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: UNKNOWN_EXCEPTION, Use one of these records?: []
below is the code-
trigger AccountAddressTrigger on Account (before insert, before update) {
try{
for(Account act : Trigger.new){
If(act.Match_Billing_Address__c == true && act.BillingPostalCode!= null)
{
act.ShippingPostalCode=act.BillingPostalCode;
}
}
}
catch(DmlException e)
{
system.debug('cause'+e.getcause());
}
}