It's important to automatically import or copy address information from an account to its contacts to ensure consistency across your CRM system. However, when you create and associate contacts to an account individually rather than through an account, the address information from the account doesn't automatically carry over. The only way out is to copy and paste manually, which will take forever. But now there's a solution!
To spare you the effort of manual work, you can create a custom function that updates the account's billing address and shipping address into a contact during its association at the click of a button. To set things up, create the function and link it to a custom button for the Contacts module. To learn more, please read the section below.
Permissions and availability
- Users with the Modules Customization permission can create custom buttons.
- Users with the Manage Extensibility permission can write custom functions.
- Users with the Manage Sandbox permission can manage the sandbox.
Requirements
- Create and link the button with the custom function, as detailed in the "Create a button" section below. Learn more
- Test the function in a sandbox before deploying it to your production environment. Learn more
Create a button
Follow the steps below to create a custom button in the Contacts module that copies the address information from the account to the contact record when clicked.
- Navigate to Setup > Customization > Modules and Fields > Contacts > Buttons > Create New Button.
- Provide a name for the button. For example: "Copy Address".
Add a description (optional). - Choose the layouts where you want the button to be placed.
- Specify the button's placement as In Record and its position on the page as Details.
- Select the action to be performed as Writing Function.
- Provide a name and display name for the function, and click Create.
- On the Deluge script editor, do the following:
- Copy and paste the code provided below.
- Click Edit Arguments.
- Enter the name as contId, select the value as Contacts - Contact Id, and then click Save.
- Save the function.
- Select the profiles who can view this custom button.
- Click Save.
The code
//Get contact record
contactMap = zoho.crm.getRecordById("Contacts",contId);
//Check if there is an account associated with the contact
if(!isnull(contactMap.get("Account_Name")))
{
info true;
accountId = contactMap.get("Account_Name").get("id");
accountMap = zoho.crm.getRecordById("Accounts",accountId);
//Prepare the field map
updateMap = Map();
//Get the account billing address and update the contact mailing address
updateMap.put("Mailing_Country",accountMap.get("Billing_Country"));
updateMap.put("Mailing_State",accountMap.get("Billing_State"));
updateMap.put("Mailing_Street",accountMap.get("Billing_Street"));
updateMap.put("Mailing_City",accountMap.get("Billing_City"));
updateMap.put("Mailing_Zip",accountMap.get("Billing_Code"));
//Get the account shipping address and update the contact other address
//Remove this section if you only want to copy billing address
updateMap.put("Other_Country",accountMap.get("Shipping_Country"));
updateMap.put("Other_State",accountMap.get("Shipping_State"));
updateMap.put("Other_Street",accountMap.get("Shipping_Street"));
updateMap.put("Other_City",accountMap.get("Shipping_City"));
updateMap.put("Other_Zip",accountMap.get("Shipping_Code"));
//
//Update the contact record
updateResponse = zoho.crm.updateRecord("Contacts",contId,updateMap);
info updateResponse;
//Return Message - Addresses copied successfully
return "";
}
else
{
//Return message when there is no account associated with the contact
return "No account associated with this contact";
}
Notes
- Make sure to use accurate API names for their corresponding fields in the code snippet. Learn more
- You can include additional custom address fields in the code snippet to transfer their information from accounts to contacts.
- The code above is an example of copying address data from an account to its related contact records. You can use this code for any other module, such as Leads or custom modules, by modifying the module name and parameters.
Tip
- Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.
Test the solution
- Click the Contacts tab.
- Open the contact record that needs to be updated with the address information from its associated account.
Note: Make sure the contact is associated with an account. - Click the new button you added to the top-right area.
- See whether the address information—such as street, city, state, country, and zip code—is copied to the contact record.
Idea
You can add a button on the account record to copy their address to all associated contacts. You only need to use the following code snippet on the custom button.
acctDetails = zoho.crm.getRecordById("Accounts",acctId.toLong());
relatedcontacts = zoho.crm.getRelatedRecords("Contacts","Accounts",acctId.toLong(),1);
//info relatedcontacts;
if(relatedcontacts.size() > 0)
{
for each ele in relatedcontacts
{
mp = Map();
mp.put("Mailing_Country",ifnull(acctDetails.get("Billing_Country"),""));
mp.put("Mailing_State",ifnull(acctDetails.get("Billing_State"),""));
mp.put("Mailing_Street",ifnull(acctDetails.get("Billing_Street"),""));
mp.put("Mailing_City",ifnull(acctDetails.get("Billing_City"),""));
mp.put("Mailing_Zip",ifnull(acctDetails.get("Billing_Code"),""));
update = zoho.crm.updateRecord("Contacts",ele.get("id"),mp);
info mp;
info update;
}
}
return "Address copied successfully";
- Map the argument key acctId to the field name Accounts - Account Id in the function.
Did you find this useful? Try it out and let us know how it works. Share this with your team if they'd benefit from it! If you have questions, please don't hesitate to contact us.
More info
- ModuleContacts
- Trigger PointCustom Button
- EditionEnterprise and above
- ComplexityLow
- Implementation Time15 minutes

Looking for a custom solution?
Contact us, we will help enhance your productivity at lightning speed.
SUBMIT REQUEST