Sync Territories for Related Modules in Zoho CRM

Difficulty: Beginner
Estimated reading time: 15 mins
Estimated implementation time: 30 mins

Core Idea

Territories are a data-sharing structure that allows you to hide certain records from users based off record-level criteria. When you assign a territory to an Account, the system automatically assigns that territory to all related Contacts. However, when there is more than one territory assigned, the workflow does not repeat (eg; if an Account is assigned Territory1, Territory2 and Territory3, the related Contacts are only assinged Territory1). This script makes sure that ALL territories assigned in an Account gets assigned to ALL related Contacts by getting the territory IDs off the Account, then assigning them in Contacts via Territories API.


Zoho CRM Connection

In order to call the Zoho CRM API within a Deluge Script, you must first create a connection to it.

Connections In Zoho CRM

  1. Go to the Zoho CRM homepage and click setup.
  2. Under Developer Space, select Connections.
  3. Click Add Connection, then select Zoho OAuth.

Zoho OAuth Connections needed:

  • ZohoCRM.modules.accounts.ALL
  • ZohoCRM.modules.ALL
  • ZohoCRM.modules.contacts.ALL

Want to learn even more? Sign up for one of our Zoho courses!


  1. Use this API to get details of the territories assigned to the Account.
  1. Create a LIST variable and use a LOOP to add all the territory IDs in the list container.
  1. Get all Related Contacts to the Account
  1. Create a LOOP to iterate through every Contacts, and another LOOP inside it to iterate through every ID in the territory ID list. Here, another API call is used to assign the territories to the Contacts.

Note: +”” is added after paramap to convert it to string for the function to work

Click here to copy these scripts. For more Zoho-wizardry, check out our GitHub page.

More Free Resources

Deluge Tips – Null Check

When scripting, ask yourself this question – will this value ever be null? If it’s a yes, that’s a place for a null check! Here are 3 tips and best practices to help you kickstart the habit.

Read More »