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
Arundhati DebArundhati Deb 

write a trigger to update one account depending on another account

We have to a update child account depending on parent account. We have the same record type for both the accounts. When a checkbox called "entity" is checked, and a look up field called parent account is filled, that account is considered a child account. Whenever a new address is added or edited on the parent account, the same should flow on child account in the same field of address.
We have to write a trigger for the same
Rameshwar gaurRameshwar gaur
if (Trigger.isUpdate)
        List<Account> Allacc = [SELECT ID,ParentId,BillingAddress,BillingCity,BillingCountry,
                                                          ShippingStreet FROM Account];
        Map<Id,Account> MapAccount = New Map<ID,Account>();
       	for(Account acc : Allacc)
        List<Account> AccountUpdate = new List<Account>();
        for(Account Acc : Trigger.New)
            if(MapAccount.get( == true){
            if(acc.ShippingAddress != Trigger.OldMap.get( || acc.BillingAddress != Trigger.OldMap.get(
                   MapAccount.get( = acc.BillingCity;
                   MapAccount.get( = acc.BillingCountry;
                   MapAccount.get( = acc.BillingPostalCode;
                   MapAccount.get( = acc.BillingState;
                   MapAccount.get( = acc.BillingStreet;
                   MapAccount.get( = acc.ShippingCity;
                   MapAccount.get( = acc.ShippingCountry;
                   MapAccount.get( = acc.ShippingPostalCode;
                   MapAccount.get( = acc.ShippingState;
                   MapAccount.get( = acc.ShippingStreet;
        Update AccountUpdate;

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
If you have any more queries or those code not work please feel free to ask i will try my best to help you.