-
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
Steps to enable Chatter and Social Media in Salesforce
Here we will learn how to enable social media and chatter in Salesforce. Let's start from a contact tab and see how it looks without…
Learn About Query Languages & DML in Salesforce
To fetch data, we have a query language in Salesforce. Below are the database query languages in Salesforce. SOQL - Salesforce object query language SOSL…
Exploring the Future of Salesforce at Dreamforce 2024: Innovations, Experiences, and Opportunities
Dreamforce 2024 has set the stage for a transformative year in the world of Salesforce technology. With over 45,000 attendees from more than 140 countries,…
Popular Salesforce Videos
Salesforce Admin Training: How to add custom fields in salesforce ?
Salesforce Custom fields :- Up to now we have created custom app, custom object and now we are going to create Salesforce custom fields. When…
Real Time Synchronization between Salesforce and Quickbooks | eShopSync for Quickbooks
Now you can easily sync your data between Quickbooks and Salesforce through Real-Time Synchronization Feature, which allows you to import data from Salesforce to Quickbooks.…
Creating an Approval Process in Salesforce with Example
Approval Process in Salesforce is an automated process that automates how Salesforce records are approved in your org. Approval Process in Salesforce is a combination…