• Sippy yowther
  • NEWBIE
  • 5 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Finally Solved this!!! below is my code

trigger AccountAddressTrigger on Account (before insert, before update) {
    for(Account acct : Trigger.new){ 
        if(acct.Match_Billing_Address__c == True){
             acct.ShippingPostalCode = acct.BillingPostalCode;   
        }
    }

https://youtu.be/sqIkewmXOZk
After you have created this trigger make sure to follow along with this tutorial, you can skip to the part where he creates the code. To test your trigger go into Saleforce classic and create a new Account record, titled whatever and make sure the match billing address is checked. Fill in the shipping address and billing address and make sure they match (you can use a seudo adress or your own).
Last step (VERY IMPORTANT) to be able to create your new account record and test the trigger to pass the test you MUST go to your AddRelatedRecord Trigger and deactivate it because that trigger is ran when creating the record, otherwise you will get an error, after you finished that you can then succesfully complete the trailhead! Hoped it helps!!!




 
I'm getting the same error even though I'm using the code provided by other users here. The new field is also created.
 
trigger AccountAddressTrigger on Account (before insert, before update) {
    for(Account a : Trigger.new){
        If (a.Match_Billing_Address__c == true) {
            a.ShippingPostalCode = a.BillingPostalCode;
        }   
    }
}

Is there anything wrong with it? 

Thanks in advance.