function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jackson DiasJackson Dias 

I have one scenario;

​Hi Experts ,
I have one scenario; I have one object Account child to contact. When account address is updated how to update  related contacts address also?
Dilip_VDilip_V
jack,

Try this code
trigger AutoPopulateMailing on Account (after update) 
{
list<Contact> conList = new list<Contact>();
Map<id,Account> AccountMap = new Map<id,Account>();
for(account acc:trigger.new)
{
    if( (acc.billingstreet!= Trigger.oldmap.get(acc.id).billingstreet) || (acc.billingstate!= Trigger.oldmap.get(acc.id).billingstate) || (acc.billingcity!= Trigger.oldmap.get(acc.id).billingcity) || (acc.billingpostalcode != Trigger.oldmap.get(acc.id).billingpostalcode) || (acc.billingcountry != Trigger.oldmap.get(acc.id).billingcountry))
        {
            AccountMap.put(acc.id,Acc);

        }
}
Map<id,Contact> Cons=new Map<id,Contact>();
for(Contact c : [SELECT id,Accountid,MailingAddress FROM Contact where Accountid in:AccountMap.Keyset()])
{
Account a=AccountMap.get(c.Accountid);
if(a.id==c.accountid)
{
c.Mailingstreet = A.billingstreet;
c.Mailingcity  = A.billingcity;
c.Mailingpostalcode = A.billingpostalcode;
c.Mailingstate = A.billingstate;
c.Mailingcountry  = A.billingcountry;
conList.add(c);
}
}
update conList;
}

Let me know if it helps.

Make it as best answer if  it helps.

Thanks.
Naveen DhanarajNaveen Dhanaraj
Hi jackson,
I would suggest you to go with Process Buider,This can be done by Admin part easily.

Auto-update Contact Address with Account's Billing Address------>https://help.salesforce.com/HTViewSolution?id=000231395