-
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
AppExchange vs Custom Development: Considering Your Options in Salesforce
Salesforce AppExchange is a marketplace of pre-built applications and components that you can install into your Salesforce organization. Custom development is the process of building…
How Salesforce CRM better than other CRM ?
Salesforce is among the world’s top cloud-based CRM software. It can help a business in becoming more efficient, streamlined, and effective. Salesforce has evolved a…
Digitization - The Way Forward For Nonprofits | Salesforce Guide
Digitization is booming in every industry, big or small, after the COVID-19 hit. As companies and organizations are working remotely, this entails signing off the…
Popular Salesforce Videos
Sharing Rules in Salesforce
Use sharing rules to extend sharing access to users in public groups, roles, or territories. Sharing rules allow administrators to automatically bypass organization-wide sharing settings.…
Salesforce Trailhead - Get Started with the Salesforce Mobile App
After watching this video you'll be able to: Identify the flavors of the Salesforce mobile app available to you. Log in to your Salesforce org…
Create Custom App in Salesforce | Salesforce Custom App | Salesforce Tutorial
Watch this amazing video to learn how to create a custom app in Salesforce. Salesforce is a cloud-based platform that has transformed how companies have…