-
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
Decoding Ineffectiveness: Recognizing Red Flags in Your Salesforce Partner Relationship
When it comes to tech partnerships, teaming up with Salesforce partner is a big deal for customer relations. But let's be real - not every…
Going Beyond Traditional Implementation Methodologies for Salesforce Service Cloud: A Fireside Chat
Salesforce Service Cloud has myriads of capabilities that enable you to ace your customer service game. But optimizing Service Cloud the right way calls for…
A Guide to Utilizing the Salesforce Customer Portal in Academia
Educational institutions have undergone significant changes over the years. Entering the early 2000s, these institutions gradually embraced technology by introducing advanced computer labs that allowed…
Popular Salesforce Videos
Create Your First Salesforce App in 30 Minutes
In this session, we will design, build and deploy a Salesforce App in 30 minutes using the low code and Salesforce modern developer tooling. Presenter…
Salesforce Apex Tutorial for beginners | Apex Salesforce Tutorial
Apex is a proprietary language developed by Salesforce.com. It is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the…
Get Started with Salesforce Elevate
Salesforce is a powerful tool to analyze your past fundraising, and monitor your ongoing efforts. In this webinar, we'll start with the fundamentals -- understanding…