Updating Multi-Select Lookup on Zoho CRM

Every Joe and Jane knows how to update lookup fields via Deluge. But when it comes to updating multi-select/user lookup fields, it can be tad bit more complicated than just sticking the “id” to the lookup field.

The “Linking Module”

Here are some cool ideas on ways you can use the code in Zoho CRM:To understand how this is done is to first understand the relationship between lookup modules. When a multi-select lookup is made between two modules (eg; Contacts & Deals), a Linking Module (Contacts_X_Deals) is created. This linking module stores information of both Contacts & Deals, allowing a many-to-many relationship to be established.

Finding the Linking Module

Here are some cool ideas on ways you can use the code in Zoho CRM:To understand how this is done is to first understand the relationship between lookup modules. When a multi-select lookup is made between two modules (eg; Contacts & Deals), a Linking Module (Contacts_X_Deals) is created. This linking module stores information of both Contacts & Deals, allowing a many-to-many relationship to be established.

The linking module, unlike regular modules in CRM, is not visible from the front-end. The way to find it is to run an API call that gets ALL modules in CRM. This function reveals all modules in CRM (including hidden ones) and its respective fields.

CRM Connections needed for API Call:

  • scope=ZohoCRM.settings.all (or)/li>
  • scope=ZohoCRM.settings.modules.{operation_type}
				
					response = invokeurl
[
	url: "https://www.zohoapis.com/crm/v2/settings/modules"
	type: GET
	connection: "INSERT YOUR CONNECTION NAME HERE"
];
info response;
				
			
Once executed, you will be greeted with a long JSON text containing every single module details in your CRM account. Stick the text in to a JSON viewer and quickly sieve through the modules to find the Linking Module you need (tip: they usually look like “Module_A_X_Module_B” Once you’ve found the module, you should see two lookup fields that links two modules (A & B) respectively. Save the module name and lookup field API names into your notes, you will need it for later.

API Name Checklist (save for later)
  • Linking Module Name
  • Lookup field name to Module A
  • Lookup field name to Module B

Updating the Multi-Select/User Lookup Field

Now that you have what you need, in order to update the lookup field, you need to create a record in the linking module with the relevant record IDs from Module A & B placed in its respective lookup fields.

This is done by creating a map of to store the lookup fields and record IDs, which will be used to create the record in the linking module.
				
					mp = Map();
mp.put("lookupfield_A", "A_record_ID");
mp.put("lookupfield_B", "B_record_ID");
create = zoho.crm.createRecord("Linking_Module_Name",mp);
				
			
  • Replace “lookupfield_A” with the lookup field name to module A (eg; Contacts) and “A_record_ID” with the relevant record ID
  • Replace “lookupfield_B” with the lookup field name to module B (eg; Deals) and “B_record_ID” with the relevant record ID
  • Replace “Linking_Module_Name” with the linking module API name (they usually look like this: Contacts_X_Deals).
Click here to copy the scripts. For more Zoho-wizardry, check out our GitHub page.

Contact Us!

Book a free 30-minutes consultation with a Zoho expert or send us an email

Related Resources