-
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 Flows and Types of Flows
Salesforce Flow enables you to construct complex business arrangements utilizing clicks, not code. Flow Builder is the most integral asset that a Salesforce Admin has…
Salesforce Financial Services Cloud Winter '24 Highlights
Winter is coming, and so is a new era of streamlined efficiency, enhanced user experience, and operational improvements in Salesforce Financial Services Cloud! Let’s cozy…
The Only Guide You Will Ever Need for Customer Self-service | Salesforce Guide
What makes the customer experience great? How well do you interact with your customers? The empathy that you show toward them Timely response to their…
Popular Salesforce Videos
In App Guidance | Salesforce Tutotial
In this video, we take a look at one of the new features from the Salesforce Summer '19 release - In-App Guidance. We explain what…
How To Set Up Gmail With Salesforce | Salesforce Development Tutorial
Learn how to set up Gmail with Salesforce. The following points will be covered in this tutorial - 1. Lightning for Gmail Get a brief…
How to Get Salesforce Developer Certification | Salesforce Certification
A Salesforce developer certification is a credential that verifies a professional has the necessary skills and knowledge to design custom applications and analytics functions on…