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
mahesh admin 3mahesh admin 3 

using trigger how to copy billing address to shipping address?

Best Answer chosen by mahesh admin 3
souvik9086souvik9086
trigger shippingAddressUpdate on Account(before insert, before update){

for(Account acc : Trigger.new){

acc.ShippingState = acc.BillingState;
acc.ShippingStreet = acc.BillingStreet;
acc.ShippingCountry = acc.BillingCountry;
acc.ShippingCity = acc.BillingCity;
}
}

All Answers

souvik9086souvik9086
trigger shippingAddressUpdate on Account(before insert, before update){

for(Account acc : Trigger.new){

acc.ShippingState = acc.BillingState;
acc.ShippingStreet = acc.BillingStreet;
acc.ShippingCountry = acc.BillingCountry;
acc.ShippingCity = acc.BillingCity;
}
}
This was selected as the best answer
Vinit_KumarVinit_Kumar
Why do you need a Trigger,you can have WF for the same..
mahesh admin 3mahesh admin 3
Thankyou it is working.

HarsReddy NarHarsReddy Nar
hi, i need by using after insert and after update can you help me?
mahesh admin 3mahesh admin 3
Hi harsha,
 
 you can do the operation using,before events why your going to after it's not abest practice.
try this
trigger shippingAddressUpdate on Account(before insert, before update){

for(Account acc : Trigger.new){

acc.ShippingState = acc.BillingState;
acc.ShippingStreet = acc.BillingStreet;
acc.ShippingCountry = acc.BillingCountry;
acc.ShippingCity = acc.BillingCity;
}
}
HarsReddy NarHarsReddy Nar
i done that with before insert and before update, but i am trying by using after insert and after update.
Laxmi Reddy 12Laxmi Reddy 12
Thank you sir.