-
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
Salesforce Nonprofit Cloud vs. NPSP: Which One to Choose?
Table of Contents Introduction Nonprofit Success Pack (NPSP) Salesforce Nonprofit Cloud Key Differences between Salesforce Nonprofit Cloud vs. NPSP Conclusion (Salesforce Nonprofit Cloud vs. NPSP)…
Dashboards in Salesforce - A Brief Guide
Dashboards in Salesforce are graphical representations of reports. Visualize data from reports as components. These components provide a summary of your organization's key analytics and…
Salesforce Sharing and Security Features
Introduction: Salesforce provides different kinds of security levels like objects, field records, etc. Data is Stored in Objects, Fields, and Records in Salesforce. Salesforce uses…
Popular Salesforce Videos
Salesforce - How Small Businesses Offer Great Customer Service
Small businesses are more than capable of offering great customer service, even without having a big call center or multiple service agents on hand. For…
Transition to Salesforce Lightning Experience
Transition to Salesforce Lightning Experience for Overall Navigation, Global Search, Home Page, Accounts, Leads and Opportunities. This video walks you through the recommended process, including…
Top 5 Benefits of Salesforce Financial Service Cloud
Built on the Salesforce Customer Success Platform, Financial Services Cloud includes an enhanced set of features created specifically for client engagement and designed with the…