-
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 AppExchange - Everything you Need to Know
Salesforce’s AppExchange is really fruitful and demanding app platform in marketplace. This cloud computing souk is hosted by Salesforce.com, here you can find thousands of…
Highly Effective Strategies To Make Salesforce Customization Work For You
There is nothing more thrilling than running your business on your terms. Thanks to Salesforce customization options, making it easier for admins to simplify the…
Salesforce Consulting Services - 8 Excellent Salesforce Tools to improve your Sales Pipeline
Ever asked any sales organization which technology they have heavily invested as an alternative to the CRM? The answer is Salesforce which has now become…
Popular Salesforce Videos
How Does SFCC (Headless Commerce) Different From Its Competitors and Why Is It Better? | Salesforce
Let's have look at which one is better SFCC, Shopify, Magento, or Woocommerce. Which one you should choose? Have a glance at this extract from…
Simplify Salesforce Development using CLI and VSCode Tasks
The Salesforce CLI is a powerful command-line interface that simplifies development and builds automation when working with your Salesforce org. Typing commands can be monotonous…
How to Edit or Change Product Schedules in Salesforce
Use product schedules to determine the payment and delivery cycles for products that are paid or delivered over time. In Lightning Experience, customize schedules with…