How to Update Multi-Select Lookup Fields via API in Zoho CRM

Update Multi-Select Lookup Fields via API in Zoho CRM - Establish many-to-many relationships using linking modules or REST API

Overview: 

Multi-Select Lookup Field in Zoho CRM allows you to establish a many-to-many relationship between two modules. This is useful when a record in one module can be linked to multiple records in another, and vice versa.

Business Example:

Let’s say your business deals with training services. You have a Trainers module and a Courses module. Each trainer can handle multiple courses, and each course can be conducted by multiple trainers. In such a case, a multi-select lookup field between Trainers and Courses allows you to easily manage and view these relationships from either module.

InfoTo learn more about Multi-Select Lookup Fields, refer to this document.

Understanding Multi-Select Lookup Field Functionality:

When a multi-select lookup field is added to a module, a corresponding multi-select lookup field is automatically created in the referenced (looked-up) module, enabling a bidirectional relationship.

Example:

If you add a multi-select lookup field for the Courses module in the Trainers module:
  • A field named Trainers will automatically be created in the Courses module.
  • If you associate Courses X, Y, and Z with Trainer A, then:

    • Trainer A will show Courses X, Y, Z in its multi-select field.
    • Course X will also display Trainer A in its corresponding multi-select lookup field.

Screenshots

  

 

Linking module:

While creating a multi-select lookup field, you also have the option to enable a Linking ModuleThe Linking Module stores the relationships between records as individual entries, helping preserve and reference the connections explicitly.



Continuing with the above example:


Linking record
        Relationship
                    Record 1

                                   Course
 X ↔ Trainer A
                      Record 2
                                   Course Y ↔ Trainer A
                      Record 3
                                   Course Z ↔ Trainer A

Screenshots







Why update Multi-Select Lookup Fields via API?

While users can manually associate records via the CRM UI, programatically updating multi-select lookup fields using API offers significant advantages:

  • Bulk Association: Easily associate multiple records in one go, especially useful for migrations or mass updates.
  • Automation: Trigger updates as part of workflows, integrations, or external business logic.
  • Efficiency: Saves time and reduces human error when handling large volumes of data.

This is particularly beneficial for partners building custom solutions, handling third-party data imports, or working with complex data relationships across modules.

How to Update a Multi-Select Lookup Field via API?


There are two approaches to update multi-select lookup fields programmatically using the Zoho CRM API.

Approach 1: Using the Linking Module

By
creating a record in the linking module, the relationship between records is established and reflected in both modules' multi-select lookup fields.

Sample Deluge Script:

  1. mp = Map();
  2. mp.put("Trainers", trainerId);
  3. mp.put("Courses", courseId);
  4. createRecord = zoho.crm.createRecord("Trainers_and_Courses", mp);
  5. info createRecord;

NotesNote:

➤ Trainers_and_Courses - API name of the linking module.
➤ Courses_Multi_Select_Lookup - API name of the multi select look-up field present in the Trainers module.
➤ Trainers_Multi_Select_Lookup = API name of the 
multi select look-up field created in the Courses module. 


Approach 2: Directly Updating Using REST API (Without Linking Module)

You can also use the CRM REST API (v2.1) to directly update the multi-select lookup field.

Sample script:

  1. // Initialise a list to store multiple course record maps
  2. recordMapsList = list(); 

  3. // Create a map for the first course with its ID and name
  4. firstCourse = Map();
  5. firstCourse.put("id",5117245000058535290);
  6. firstCourse.put("name","Course Y");

  7. // Wrap the first course inside another map using the lookup field API name
  8. courseOneMap = Map();
  9. courseOneMap.put("Courses_Multi_Select_Lookup",firstCourse);

  10. // Add the first course map to the list
  11. recordMapsList.add(courseOneMap);

  12. // Create a map for the second course with its ID and name
  13. secondCourse = Map();
  14. secondCourse.put("id",5117245000058535300);
  15. secondCourse.put("name","Course Z");

  16. // Wrap the second course inside another map using the same lookup field API name
  17. courseTwoMap = Map();
  18. courseTwoMap.put("Courses_Multi_Select_Lookup",secondCourse);

    // Add the second course map to the list
  19. recordMapsList.add(courseTwoMap);

  20. // Create the final map for the multi-select lookup field
  21. multiSelectLookupFieldMap = Map();
  22. multiSelectLookupFieldMap.put("Courses_Multi_Select_Lookup",recordMapsList);

  23. // Add the field map to a list under the "data" key (required format for CRM API)
  24. data = list();
  25. data.add(multiSelectLookupFieldMap);

  26. // Create the final payload to send in the PUT request
  27. payload = Map();
  28. payload.put("data",data);

  29. // Make the API call to update the Trainer record with the associated courses
  30. updateRecord = invokeurl
  31. [
  32. url :"https://www.zohoapis.com/crm/v7/Trainers/5117245000059509243"
  33. type :PUT
  34. parameters:payload.toString()
  35. connection:"zohocrm"
  36. ];
  37. info updateRecord;

Note:

➤ Trainers - API name of the module where the multi-select lookup field for Courses exists.
➤ Courses_Multi_Select_Lookup - API name of the multi-select lookup field in the Trainers module. 

Conclusion:

Using either the Linking Module approach or the direct REST API update, you can effectively manage and automate multi-select lookup relationships in Zoho CRM. Choose the method that best fits your integration scenario.

Custom Solution Created by Yogeshwari N | Zoho Partner Support

If you need any further clarifications, please don’t hesitate to contact partner-support@zohocorp.com.

Additionally, we kindly ask all Europe and UK Partners to reach out to partner-support@eu.zohocorp.com.