Zoho Books' integration with Zoho CRM enables you to synchronize contacts, companies, and products between Zoho Books and CRM so that you can manage and track crucial CRM and accounting information in a single location. However, you may encounter situations where a contact is present in your CRM database but not in Books. In such circumstances, you can add the contact to Books immediately with the click of a button.
Since this is a rare scenario—contacts usually stay in sync when the integration is enabled—we support it through our low-code tools. This custom function helps you create a Zoho Books contact from inside a CRM contact record with the help of a custom button. You can add this button to the Contacts detail view page in any preferred order.
Permissions and availability
- Users with the Manage Extensibility permission can create connections and write custom functions.
- Users with the Modules Customization permission can create custom buttons
- Users with the Manage Sandbox permission can manage the sandbox.
Requirements
- Create a Zoho Books connection with the required scopes for your Zoho CRM account, as detailed in the "Create Connection" section below. Learn more
- Create and link the button with the custom function, as detailed in the "Create Button" section below. Learn more
- Test the function in a sandbox before deploying it in your production environment. Learn more
Create a connection
Follow the steps below to create an OAuth connection in your Zoho CRM account:
- Go to Setup > Developer Space > Connections.
- Click Create Connection.
- Select Zoho Books under Default Services.
- Specify a Connection Name.
You must enter this name in the code snippet below. - Select the following Scope to request access.
- ZohoBooks.fullaccess.all Learn more
- Click Create and Connect.
- Click Connect and then click Accept to confirm authorization of access for the scopes requested by the client.
Create a button
Follow the steps below to create a custom button in your Zoho CRM account:
- Go to Setup > Customization > Modules and Fields > Contacts > Buttons > Create New Button.
- Provide a name for the button. For example: "Create ZBooks contact".
Add a description (optional). - Choose the layout(s) you want the button to be placed.
- Specify the button's placement as In Record and its position on the page as Details.
You can also choose to add the button to the In List - Util Menu. - 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 contactId and select the value as Contacts - Contact Id.
- Save the function.
- Select the profiles that can view this custom button.
- Click Save.
The code
contact = zoho.crm.getRecordById("Contacts", contactId);
info "Contact Record : " + contact;
accountName = ifnull(contact.get("Account_Name"),"").get("name");
fName = contact.get("First_Name");
lName = contact.get("Last_Name");
email = contact.get("Email");
phone = contact.get("Phone");
street = contact.get("Mailing_Street");
city = contact.get("Mailing_City");
state = contact.get("Mailing_State");
country = contact.get("Mailing_Country");
zip = contact.get("Mailing_Zip");
contact_persons = List();
contactperson = Map();
contactperson.put("first_name",fName);
contactperson.put("last_name",lName);
contactperson.put("email",email);
contactperson.put("phone",phone);
contact_persons.add(contactperson);
address = Map();
address.put("zip",zip);
address.put("country",country);
address.put("address",street);
address.put("city",city);
address.put("state",state);
booksContactInfo = Map();
booksContactInfo.put("contact_persons",contact_persons);
booksContactInfo.put("billing_address",address);
booksContactInfo.put("contact_name",accountName);
info "Books Contact Info Map : " + booksContactInfo;
createCustomer = zoho.books.createRecord("Contacts","OrgID",booksContactInfo,"connectionname");
info "Create Customer : " + createCustomer;
return "success";
Notes
- Replace 'OrgID' with the Organization ID obtained from Zoho Books.
- Replace 'connectionname' with the name of the Zoho Books connection.
- Make sure to use the accurate API names for their corresponding fields in the code snippet. Learn more
- The code above will add the CRM's contact and associated account as a contact person and customer in Zoho Books, respectively.
Tips
- You can skip setting up a Zoho Books connection by configuring the Zoho Finance Suite integration within Zoho CRM. In such cases, you must remove the connection name placeholder from the code snippet.
- Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.
Test the solution
- Navigate to the Contacts module.
- Select a contact record that has an associated account.
Verify that the contact is not already present in Zoho Books. - Click the button you added via the above steps from the details page.
- Check whether the contact was added to your Zoho Books account.
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
- ComplexityMedium
- Implementation Time30 minutes

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