Copy Billing Address to Shipping Address

If the “CopyBillingToShipping” checkbox is selected, this trigger copies the Account’s billing address to its shipping address. It automates address management for consistency.

Practice triggers here: YouTube playlist.

Solution:

trigger AccountTrigger on Account (before insert) {

             if(Trigger.isInsert){ if(Trigger.isBefore){
                   AccountTriggerHandler.updateRating(Trigger.New);
             }
     }
}

public class AccountTriggerHandler {

          public static void updateAddres(List <Account>accList){ for(Account acc:accList){
               if(acc.CopyBillingToShipping__c && acc.acc.BillingCity!= null
               && acc.BillingCountry!= null
               && acc.BillingPostalCode != null
               && acc.BillingState != null && acc.BillingStreet != null){
               acc.ShippingCity=acc.BillingCity;
               acc.ShippingCountry=acc.BillingCountry;
               acc.ShippingPostalCode=acc.BillingPostalCode;
               acc.ShippingState=acc.BillingState;
               acc.ShippingStreet=acc.BillingStreet;
          }
      }
   }
}

Want to Apply As Content Writer?

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart

Let's get you started!

Interested in writing Salesforce Content?

Fill in this form and we will get in touch with you :)