Trigger:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Manoj Dega | |
* @date 21 July 2018 | |
* @description Trigger for account object | |
*/ | |
trigger AccountTrigger on Account (before insert, before update) { | |
if(trigger.isBefore && (trigger.isInsert || trigger.isUpdate)) { | |
AccountHelperClass.updateShipToAsBillTo(trigger.new); | |
} | |
} |
Helper class:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Manoj Dega | |
* @date 21 July 2018 | |
* @description Helper class for Account Trigger | |
*/ | |
public class AccountHelperClass { | |
/** | |
* @author Manoj Dega | |
* @date 21 July 2018 | |
* @description This method is update the Billing address to shipping address | |
* @Context Mode Before Insert/Before Update | |
*/ | |
public static void updateShipToAsBillTo(List<Account> accountList) { | |
for(Account acc: accountList) { | |
if(acc.Same_as_BillTo__c == true) { | |
acc.ShippingStreet = acc.BillingStreet; | |
acc.ShippingCity = acc.BillingCity; | |
acc.ShippingState = acc.BillingState; | |
acc.ShippingCountry = acc.BillingCountry; | |
acc.ShippingPostalCode = acc.BillingPostalCode; | |
acc.ShippingLatitude = acc.BillingLatitude; | |
acc.ShippingLongitude = acc.BillingLongitude; | |
} | |
} | |
} | |
} |