Skip to content

Instantly share code, notes, and snippets.

@ganmahmud
Last active November 21, 2018 06:38
Show Gist options
  • Select an option

  • Save ganmahmud/555b84785cfdd656ea0fb3ef626688b1 to your computer and use it in GitHub Desktop.

Select an option

Save ganmahmud/555b84785cfdd656ea0fb3ef626688b1 to your computer and use it in GitHub Desktop.
Create an Apex trigger for Account that matches Shipping Address Postal Code with Billing Address Postal Code based on a custom field.
trigger AccountAddressTrigger on Account (before insert, before update) {
for(Account a : Trigger.new){
If (a.Match_Billing_Address__c == true && a.BillingPostalCode!=Null) {
a.ShippingPostalCode = a.BillingPostalCode;
System.debug('ShippingPostalCode: '+a.ShippingPostalCode);
System.debug('BillingPostalCode: '+a.BillingPostalCode);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment