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
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

A AnanthiA Ananthi
Hi ... i have count the field "is active " from contact object and should populate the value in "Total active contacts" in account object.
can anyone help me i'm new to codings..