Skip to content

Instantly share code, notes, and snippets.

@cdeckert
Created February 11, 2020 07:07
Show Gist options
  • Save cdeckert/38c913df023dcc780001d32837cc497c to your computer and use it in GitHub Desktop.
Save cdeckert/38c913df023dcc780001d32837cc497c to your computer and use it in GitHub Desktop.
// copy mailing street to contact
trigger on Account (before insert, before edit)
{
List<Account> accounts = [SELECT ID, MailingStreet FROM Account WHERE AccountId = trigger.new];
for(int i = 0; i < accounts.length(); i++)
{
Account a = accounts[i];
List<Contact> contacts = [SELECT ID, MalingStreet from Contact WHERE AccountId = a.Id];
for(Contact c : contacts)
c.MailingStreet = a.MailingStreet;
update c;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment