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
kaustubh chandratrekaustubh chandratre 

user updating account record,if billing address is change update all its child contacts mail address field same as account billing address using trigger

PriyaPriya (Salesforce Developers) 
Hey Kaustubh,

Kindly refer the sample code and modify it accordingly :-
trigger changeShippingAddress on Account (before insert){
for(Account aObj : Trigger.new){
//We should first check whether the user is passing null data
if(aObj.BillingStreet!=null){
aObj.ShippingStreet=aObj.BillingStreet;
}
if(a.BillingCity!=null){
aObj.ShippingCity=aObj.BillingCity;
}
if(a.BillingState!=null){
aObj.ShippingState=aObj.BillingState;
}
if(a.BillingPostalCode!=null){
aObj.ShippingPostalCode=aObj.BillingPostalCode;
}
if(a.BillingCountry!=null){
aObj.ShippingCountry=aObj.BillingCountry;
}
}
}

It would be difficult for the community to provide the complete implementation of test class. Hope you understand this. However, we can help you with error if you face any in your test code.

 

Thanks & Regards,

Priya Ranjan