-
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 Lightning Tutorials with Sample Code
Salesforce Lightning Framework is the Customer-focused UI designed to build powerful dynamic apps for mobile, web, and desktop devices. The task of a Salesforce developer…
Streamlining Operations of a Leading Bike Aggregator Through Salesforce® Field Service Lightning
Client Profile The client is a leading Bike Aggregator in the US, a start-up that has recently raised multi-million-dollar investment. They have a public-private partnership…
Here’s what makes Field Service Lightning the fastest growing product of Salesforce
In the era of Digital Transformation, Customer Experience (CX) is the new battleground, and delivering superior CX has never been more important. In fact, according to…
Popular Salesforce Videos
Salesforce Sales Engagement Mastery: Proven Strategies for Efficiency and Success
Salesforce stands as a cloud-based customer relationship management (CRM) software capable of revolutionizing sales procedures and enhancing the efficiency of internal sales representatives. This dynamic…
How to Execute a SOQL Query in POSTMAN?
Watch this video to learn how to execute a SOQL Query in POSTMAN. If you have any doubts or questions, let us know in the…
Can I Get a Job by Just Learning Salesforce Admin?
In this Video Shrey covered the following questions: 1. Can I get a job by just learning Salesforce Admin? 2. Can you start a career…