You need to sign in to do that
Don't have an account?
Apex Triggers Error
Hi All,
Below are the requirements to complete Challenge
The Account object will need a new custom checkbox that should have the Field Label 'Match Billing Address' and Field Name of 'Match_Billing_Address'. The resulting API Name should be 'Match_Billing_Address__c'.
With 'AccountAddressTrigger' active, if an Account has a Billing Postal Code and 'Match_Billing_Address__c' is true, the record should have the Shipping Postal Code set to match on insert or update.
I have created new custom Checkbox(MatchBillingAddress) and Below is my trigger:
trigger AccountAddressTrigger on Account (before insert, before update) {
for(Account a:Trigger.New){
If (a.Match_Billing_Address__c && a.BillingPostalCode!= Null) {
a.BillingPostalCode= a.ShippingPostalCode ;
}
}
}
Im getting the following error message :
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: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AddRelatedRecord: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c] Trigger.AddRelatedRecord: line 23, column 1: []
I had same errors on both my demo triggers as well.Please drop your suggestions.:)
It look like you created one field "Discount_Percent__c" as required field. Please edit the field and uncheck the required checkbox and try your challenge again.
Let us know of this will help you
Try this : Regards,
Ajay
Thank you for your suggestions,I have completed the challenge.