Ask Search:
Matthew JohnsonMatthew Johnson 

Copy Shipping Address to Billing Address?

We use the shipping address as our primary client address.  The billing address is sometimes the same as the shipping address. 

Is there a way to copy the shipping address to the billing address field?  A button, perhaps?

We are on Professional Edition. 

Steve MolisSteve Molis
 There should be a link in the header of the Account Address Information Section that says
"Copy Billing Address to Shipping AddressAddress Information"

Steve MolisSteve Molis
 Sorry Matt, I misread your post, if you need to reverse it you'll probably have to hack the Javascript behind the standard link and "roll your own" Custom Link or Button.
Matthew JohnsonMatthew Johnson
Thanks, SteveMo.  Appreciate the advice.  I think we will have to build a custom button. 

Thanks again.........Matt
Chris InouyeChris Inouye
 Alternatively, you can rename Shipping to Billing and Billing to Shipping in the Setup section "Rename Tabs & Labels."  Then Shipping Address would appear on the left and billing on the right. A little confusing for the admin, but straightforward for the user. 
Tony KayyaliTony Kayyali
@SteveMo I have a need to modify the JavaScript behind the copy link. Is that doable? I prefer not to create a link of button. 


Steve MolisSteve Molis

You're asking the wrong guy about JavaScript, as Dirty Harry said at the end of Magnum Force "A man's got to know his limitations"
Tony KayyaliTony Kayyali

lol! Thanks man
Bijay SahaBijay Saha
Hi Tkay/Stevemo,

I just tried to use a javacript behind that link in visual force page.

I am overriding New button of the account with the visual force page,there in the Address Information Section i have added one link Called Copy Mailing Address to Residence address and it works fine with javascript that i have used.

Here is my Code:
<script type="text/javascript">
            function copyAddress() {
                // Variables for Residence Address
                var copy_ResidenceAddressType = document.getElementById('j_id0:j_id1:accountBlock:addressInformationSection:residenceAddressType').value;
                var copy_ShippingStreet =document.getElementById('j_id0:j_id1:accountBlock:addressInformationSection:shippingStreet').value;
                var copy_ShippingCity = document.getElementById('j_id0:j_id1:accountBlock:addressInformationSection:shippingCity').value;
                var copy_ShippingState = document.getElementById('j_id0:j_id1:accountBlock:addressInformationSection:shippingState').value;
                var copy_ShippingPostalCode = document.getElementById('j_id0:j_id1:accountBlock:addressInformationSection:shippingPostalCode').value;
                var copy_ShippingCountry = document.getElementById('j_id0:j_id1:accountBlock:addressInformationSection:shippingCountry').value;
                // Copying the Mailing Adress to the Residence Address
                if(copy_ResidenceAddressType != null)
                    document.getElementById('j_id0:j_id1:accountBlock:addressInformationSection:mailingAddressType').value = copy_ResidenceAddressType;
                if(copy_ShippingStreet != null) {
                    document.getElementById('j_id0:j_id1:accountBlock:addressInformationSection:billingStreet').value = copy_ShippingStreet;
                if(copy_ShippingCity != null) {
                    document.getElementById('j_id0:j_id1:accountBlock:addressInformationSection:billingCity').value = copy_ShippingCity;
                if(copy_ShippingState != null) {
                    document.getElementById('j_id0:j_id1:accountBlock:addressInformationSection:billingState').value = copy_ShippingState;
                if(copy_ShippingPostalCode != null) {
                    document.getElementById('j_id0:j_id1:accountBlock:addressInformationSection:billingPostalCode').value = copy_ShippingPostalCode;
                if(copy_ShippingCountry != null) {
                    document.getElementById('j_id0:j_id1:accountBlock:addressInformationSection:billingCountry').value = copy_ShippingCountry;
<apex:pageBlock title="Organization Edit" mode="Edit" id="accountBlock">
            <apex:pageblockbuttons >
                <apex:commandbutton action="{!save}" value="Save" />
                <apex:commandbutton action="{!saveAndNew}" value="Save & New" />
                <apex:commandbutton action="{!Cancel}" value="Cancel" />
 <!-- Address Information Section -->
            <apex:pageBlockSection collapsible="True" title="Address Information" columns="2" id="addressInformationSection"  >
                <A HREF="#" onClick="return copyAddress();">Copy  Mailing Address to Residence Address</A>
                <apex:inputField value="{!acc.MailingAttention__c}"/>
                <apex:outputText ></apex:outputText>
                <apex:inputField value="{!acc.MailingInCareOf__c}"/>
                <apex:outputText ></apex:outputText>
                <apex:inputField value="{!acc.MailingAddressType__c}" id="mailingAddressType"/>
                <apex:inputField value="{!acc.ResidenceAddressType__c}" id="residenceAddressType"/>
                <apex:inputField value="{!acc.BillingStreet}" id="billingStreet"/>
                <apex:inputField value="{!acc.ShippingStreet}" id="shippingStreet"/>
                <apex:inputField value="{!acc.BillingCity}" id="billingCity"/>
                <apex:inputField value="{!acc.ShippingCity}" id="shippingCity"/>
                <apex:inputField value="{!acc.BillingState}" id="billingState" />
                <apex:inputField value="{!acc.ShippingState}" id="shippingState"/>
                <apex:inputField value="{!acc.BillingPostalCode}" id="billingPostalCode"/>
                <apex:inputField value="{!acc.ShippingPostalCode}" id="shippingPostalCode"/>
                <apex:inputField value="{!acc.BillingCountry}" id="billingCountry"/>
                <apex:inputField value="{!acc.ShippingCountry}" id="shippingCountry"/>

Hope it will you.

Let me know if you find any issue.
Bijay SahaBijay Saha

Hi SteveMo,
I saw your page layout in the address information  page block section you have added the Link "Copy Billing Address to Shipping Address".

I am not sure how to add the link in the page block section (in Visualforce page):

Currently i am using this tag:
<apex:pageBlockSection collapsible="True" title="Address Information" columns="2" id="addressInformationSection"  >
                <A HREF="#" onClick="return copyAddress();">Copy  Mailing Address to Residence Address</A>

But it is not coming according to the page layout you have put.

Could you please help me on this ,how you added the link in the page block section in the same row with Section title "Address Information".

Saurabh DhobleSaurabh Dhoble
The best way is to create a custom visualforce page that mimicks the functionality of the standard account edit page, but copies the shipping address into the billing address using javascript. You can find the code etc. in this blog post.
Jayson SchoeberleinJayson Schoeberlein
@SteveMolis I am actually just looking for the button you mentioned.  Your screen cast URL link failed.  Can you relink that so I can see what you were describing?  Thank you very much.

Steve MolisSteve Molis
Hi Jayson,
That post is so old I don't even get email alerts on it anymore, I just stumbled onto it.  

Anyway, are you looking for this?  

User-added image

Jayson SchoeberleinJayson Schoeberlein
Yes that would be very helpful.  I can't seem to figure out how to create that link.  I am a newbie to customizing Salesforce.  Any guidance is greatly appreciated.
Steve MolisSteve Molis
You don't need to customize it, it's a standard part of SFDC.  Can you post a screenshot of what you see in the Address Section when you edit an Account detail record?
Jayson SchoeberleinJayson Schoeberlein
I just figured it out, thank you.  I had the "address section" header hidden when editing, that removed that link.  So I checked make it visable during edit and it is working now.  Thank you for your help.
Steve MolisSteve Molis
That'll do it every time!
Jeff LockardJeff Lockard
@SteveMo - Do you know if it's possible to get the standard "copy-billing-to-shipping" functionality as a button on the Account Page layout, without having to navigate to the Edit page to click the standard link?