How to update custom multi-user field in Zoho Projects?
I'm trying to update custom multi-user fields in Zoho Projects via a Deluge function in CRM.
The code I have so far is below. It works for updating standard project fields and single-line custom fields, but it does not work to update multi-user fields. I assume the problem is the format I'm passing the multi-user data in.
I'd love some help!
- void automation.updateProjectExample()
- {
- // Get custom fields for the portal
- fieldsResponse = invokeurl
- [
- url: "https://projectsapi.zohocloud.ca/restapi/portal/your_portal_name/projects/customfields/"
- type: GET
- connection: "your_connection_name"
- ];
- info fieldsResponse;
- // Map field names to field IDs
- fieldMap = map();
- for each field in fieldsResponse.get("project_custom_fields")
- {
- fieldName = field.get("field_name");
- fieldID = field.get("field_id");
- fieldMap.put(fieldName, fieldID);
- }
- info fieldMap;
- // Get related instructors from a CRM deal
- dealId = 1234567890; // Example Deal ID
- deal = zoho.crm.getRecordById("Deals", dealId);
- dealName = deal.get("Deal_Name");
- projectId = 9876543210; // Example Project ID
- instructors = zoho.crm.getRelatedRecords("Instructors", "Deals", dealId);
- instructorOneUsers = list();
- instructorTwoUsers = list();
- customizerUsers = list();
- // Organize users by role
- for each instructor in instructors
- {
- role = instructor.get("Role");
- zpuid = instructor.get("Zoho_Projects_user_ID"); // The instructor's Zoho Projects user id is stored in this field
- if(role == "Instructor one")
- {
- instructorOneUsers.add(zpuid);
- }
- else if(role == "Instructor two")
- {
- instructorTwoUsers.add(zpuid);
- }
- else if(role == "Customizer")
- {
- customizerUsers.add(zpuid);
- }
- }
- // Build payload for updating the project. Updating these standard fields works.
- payload = Map();
- payload.put("description", "Updated via Deluge script");
- payload.put("start_date","11-01-2025");
- payload.put("end_date","11-01-2026");
- // Example of updating a single-line custom field. This works.
- payload.put("UDF_CHAR20", "Sample text for testing");
- // Example of updating a multi-user custom field (Instructor One). This does not work.
- payload.put("UDF_MULTIUSER1", "4320000000540073"); // Replace with actual user IDs
- // Make the API call to update the project
- resp = invokeurl
- [
- url: "https://projectsapi.zohocloud.ca/restapi/portal/your_portal_name/projects/" + projectId + "/"
- type: POST
- parameters: payload
- connection: "your_connection_name"
- ];
- info resp;
- }