• Ravi Mishra 58
  • -1 Points
  • Member since 2019

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2
When attempting to create my Apex trigger for this Trailhead development exercise, I receive an error. I don't understand how this is possible, because the records haven't been updated, and still aren't updating.
"Challenge not yet complete... here's what's wrong:
Setting 'Match_Billing_Address__c' to false updated the records anyway. The trigger should only act when Match_Billing_Address__c is true."

Here's my code:
trigger AccountAddressTrigger on Account (before insert, before update) {

    for(Account a : Trigger.new){
        If (a.Match_Billing_Address__c = true) {
            a.ShippingPostalCode = a.BillingPostalCode;



OK so I've been an admin for about 3 years and (for better or worse) know more about SF than anyone in my company.  i have some experience with apex and Visualforce, but little with triggers.


what i need is to write a trigger in production that does this:  the trigger should create a new record in a custom object called "Vehicles" when an Opportunity record is created with a specific value in one of its custom fields (the field is called "Type").  So, when an opp is created and saved with Type = "x", then the trigger should fire, and a new vehicle object record should be created that is populated with a few fields from that opportunity record.


can anyone send me some code to show me what this trigger should be or look like?  I've been researching this but have no clue, and I'm afraid of writing bad code that will cause problems.


also, the custom object is not in a parent-child relationship with the opporuntiy object, and i don't want it to be unless it has to be.


i know the developers in here are ridiculously smart and talented, and i'm just hoping one of you feels sorry enough for an amateur like me to help me out.  thanks a lot.