-
How this is updating contact's mailing address related to account's billing address?
trigger ContactMailAddr on Contact (before insert, before update) { set<id> setofaccountIds=new set<id>(); for(Contact contact:trigger.new) { if(contact.AccountId!=null) { setofaccountIds.add(contact.AccountId); } } map<id,account> accountmap=new map<id,account>([select id, billingCity, billingState, billingpostalcode, billingStreet, billingCountry from account where id in :setofaccountIds]); for(contact contact :trigger.new) { contact.MailingCity = accountmap.get(contact.AccountId).billingCity; contact.MailingState = accountmap.get(contact.AccountId).billingState; contact.MailingStreet = accountmap.get(contact.AccountId).billingStreet; contact.MailingCountry = accountmap.get(contact.AccountId).billingCountry; contact.MailingPostalCode = accountmap.get(contact.AccountId).billingpostalcode; } }
Log In to reply.
Popular Salesforce Blogs

Sneak Peek: Latest Features And Updates of Salesforce commerce Cloud
With rising customer expectations in a tech-savvy marketplace, it has become critical for retailers to deliver top-shelf shopping experiences to stay relevant and competitive in…

Salesforce Lightning: Two Thumbs Up
How Your Organization and Users Benefit from Salesforce Lightning Implementation Salesforce has offered the Lightning Experience for over two years, and every release update is…

Salesforce Marketing Cloud’s Einstein Just Got Better!
Cometh the update, cometh the improvements! With the recent June ‘21 release, Marketing Cloud has seen a couple of key improvements made within the Einstein…
Popular Salesforce Videos
Auditing Account Deletion Using Salesforce Flow
This demo video walks through an example of Auditing Account Deletion Using Salesforce Flow Ever had an instance where users have accidentally deleted Accounts and…
How to Setup Salesforce Customer Community?
Step by step Salesforce tutorial for quickly setting up a Customer Community with Customer Service (Napili) Template.
How to Send a Pardot Email with Multiple Line Items | Salesforce
It is impossible to send a Pardot email that has a list of related records… or is it? In this session, Adam Erstelle uncovers strategies…