+ Start a Discussion
narensfdcnarensfdc 

Trigger for moving billing address to shipping address

Hi

  

      Please help me in writting a trigger for moving billing address to shipping address for both insert and update events

 

 thanks

 naren.

Best Answer chosen by Admin (Salesforce Developers) 
Sfdc11Sfdc11

trigger copyBillingAddress on Account (before insert,before update) {

for (Account acc: Trigger.new) {
    acc.ShippingState =acc.BillingState;
    acc.ShippingCity =acc.BillingCity;
    acc.ShippingCountry=acc.BillingCountry;
  }
}

All Answers

Sfdc11Sfdc11

trigger copyBillingAddress on Account (before insert,before update) {

for (Account acc: Trigger.new) {
    acc.ShippingState =acc.BillingState;
    acc.ShippingCity =acc.BillingCity;
    acc.ShippingCountry=acc.BillingCountry;
  }
}

This was selected as the best answer
Vinit_KumarVinit_Kumar

You can use WF in place of Trigger for this requirement.


 

narensfdcnarensfdc

Hi kavi 

 

           Thanks for your reply

 

naren

Prady01Prady01

Hey there! this is pretty simple, Anyhow here you go!

trigger moveAddressonAccount on Account (before insert, before Update) {

    for(Account acc: Trigger.new){
        acc.ShippingCity = acc.BillingCity;
        acc.ShippingStreet = acc.BillingStreet;
        acc.ShippingState = acc.BillingState ;
        acc.ShippingState = acc.BillingState;
        acc.ShippingCountry = acc.BillingCountry;
    }
    

}

 Hope it helps!

 

Thanks

Prady

narensfdcnarensfdc

Hi vinit

 

            I think we can not do it by WF,if yes,please let me know how can we give the condition in field update

 

thanks

naren

narensfdcnarensfdc

Hi kavi

 

             This trigger is fine but know there is a requirement that the whole billing address should match with shipping address but only the shipping street should differ that means what ever we enter in the shipping street it shouls take that value not the billing street value,please help me in coding this.

 

thanks

naren.

narensfdcnarensfdc

Hi prady

 

             This trigger is fine but know there is a requirement that the whole billing address should match with shipping address but only the shipping street should differ that means what ever we enter the value in shipping street it should take that different value not the billing street value,please help me in coding this.

 

thanks

naren.

Prady01Prady01

Just comment out the Shipping street and billing street line from the code!!

 

 

 

 

Thnaks

Prady