Create an Apex trigger for Account that matches Shipping Address Postal Code with Billing Address Postal Code based on a custom field
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).
- The Apex trigger must be called ‘AccountAddressTrigger’.
- 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.
Create an Apex trigger for Opportunity that adds a task to any opportunity set to ‘Closed Won’
To complete this challenge, you need to add a trigger for Opportunity. The trigger will add a task to any opportunity inserted or updated with the stage of ‘Closed Won’. The task’s subject must be ‘Follow Up Test Task’.
- The Apex trigger must be called ‘ClosedOpportunityTrigger’
- With ‘ClosedOpportunityTrigger’ active, if an opportunity is inserted or updated with a stage of ‘Closed Won’, it will have a task created with the subject ‘Follow Up Test Task’.
- To associate the task with the opportunity, fill the ‘WhatId’ field with the opportunity ID.
- This challenge specifically tests 200 records in one operation.
Hi Jie. I’ll be very thankful to you if you help me. I’m stuck with this: Create an Apex trigger for Opportunity that adds a task to any opportunity set to ‘Closed Won’
I did exactly as you show in your video but there is an 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: [Discount_Percent__c]: [Discount_Percent__c]
What ca n I do with this?
Hi Maxim, as the error message suggested, Discount_Percent__c field is missing.
Login to your org
Go to the Trigger and click on Edit and Uncheck the IsActive box and click Save
you have to deactivate active triggers on Account Object