-
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
Wrapper Classes in Salesforce: Simplifying Complex Data Handling
Introduction: As a Salesforce developer, you've likely encountered scenarios where you need to work with complex data structures, such as lists or maps, to process…
Unleash the True Potential of Salesforce with Professional Administration Services
There are fair chances that you are sold out on the expansive range of features and benefits that Salesforce offers. However, the issue arises when…
Most Essentials Tools for Building Salesforce Lightning Components
Any Salesforce developer who wants to be at the top of his game should know how to work well with Lightning Components. With Lightning Components,…
Popular Salesforce Videos
Why Sinergify is best-of-breed Salesforce-Jira Connector
Salesforce and Jira Integration have been simplified with Sinergify. The product allows for seamless integration between both instances and offers numerous benefits including effective collaboration…
What is Validation Rule in Salesforce? Explain in details
Validation Rule will check the data entered by user during insert or update the operation and as per that it will actually take the action.…
5 Important Topics to Crack Salesforce Platform Developer 1 Exam
In this video, Shrey gives you an important topic which gonna be really very helpful for crack the Platform Developer 1 Certification. Without mastering these…