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
Prakhyat sapraPrakhyat sapra 

if account billing address is update then the contacts mailing address is also update & use the old map in this???

if account billing address is update then the contacts mailing address is also update & use the old map in this???
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Prakhyat,

Can you check the solution int the below question. I hope this should solve your question. 

https://developer.salesforce.com/forums/?id=906F000000091h3IAA

Let me know if you face any issue.

If this solution helps, please mark it as best answer.

Thanks,
 
Prakhyat sapraPrakhyat sapra
can you explain this to me?
Prakhyat sapraPrakhyat sapra
what is done in this ??????
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Prakhyat,

The solution provided by SFDCfox will work I guess. Here we are comparing if there is any change in phone number or billing address fields. You can remove those phone number condition and if there is any change we are quering the contacts and updtaing the contact Mailing address with Account Billing address.

Thanks,
 
Prakhyat sapraPrakhyat sapra
It give null point expectation
Prakhyat sapraPrakhyat sapra
it is not working. it gives the null expectation
Sai PraveenSai Praveen (Salesforce Developers) 
Can you share me the code and the line where excatly you are getting the error so i can check on it.

Thanks.
 
Prakhyat sapraPrakhyat sapra
Sure, here it is. public class UpdateContactFromAccountClass { public static void UpdateUpdatecontact(List newList){ Contact[] UpdateContacts = new Contact[0]; Account[] ChangedAccounts = new Account[0]; for(account acc : Trigger.new){ if(acc.BillingStreet != trigger.oldmap.get(acc.id).billingstreet || acc.BillingCity != trigger.oldmap.get(acc.id).billingcity || acc.BillingState != trigger.oldmap.get(acc.id).billingstate || acc.BillingPostalCode != trigger.oldmap.get(acc.id).billingpostalcode || acc.BillingCountry != trigger.oldmap.get(acc.id).BillingCountry) { changedAccounts.add(acc); } for(Contact con:[select id,accountid,mailingstreet,mailingcity,mailingpostalcode,mailingcountry,mailingstate from contact where accountid in :trigger.new]) { Account acco = trigger.newmap.get(con.accountid); boolean updatedrecord = false; if(con.mailingstreet == trigger.oldmap.get(con.accountid).billingstreet) { con.mailingstreet = acc.billingstreet; updatedrecord = true; } if(con.mailingcity == trigger.oldmap.get(con.accountid).billingcity) { con.mailingcity = acc.billingcity; updatedrecord = true; } if(con.mailingstate == trigger.oldmap.get(con.accountid).billingstate) { con.mailingstate = acc.billingstate; updatedrecord = true; } if(con.mailingpostalcode == trigger.oldmap.get(con.accountid).billingpostalcode) { con.mailingpostalcode = acc.billingpostalcode; updatedrecord = true; } if(con.mailingcountry == trigger.oldmap.get(con.accountid).billingcountry) { con.mailingcountry = acc.billingcountry; updatedrecord = true; } if(updatedrecord) { updatedcontacts.add(con); } } update updatedcontacts; } } } trigger UpdateContactFromAccount on Account (Before Insert) { if(Trigger.isBefore){ if(Trigger.isInsert){ UpdateContactFromAccountClass.Updatecontact(Trigger.old); } } } sir please chack this