How to insert a ZohoUser in a subform field?
I am building an new external web app that uses the ZohoCRM REST API (v8) to push data to Zoho.
How do I use the ZohoCRM REST API to insert ZohoUsers into a subform field? I've tried several approaches and none of them have worked - inserting the ID as a string, inserting an object with an "id" attribute.
Here's relevant information from my schema -
Allocations (Custom Module)
- Sales_Order: lookup to Sales_Orders (just here so you can see how this relates to other Modules)
- Partner_Allocation: subform, Partner_Allocation
Partner_Allocation
- Parent_Id: lookup → lookup to "Allocations"
- Partner: lookup → lookup to "ZohoUsers"
And here my console log that includes the payload I am sending and the error I get when I try to PUT a new value. This works correctly if I *don't* pass in a value for Partner, but I want to set this value.
- [Zoho] PUT https://www.zohoapis.com/crm/v8/Allocations
- Payload: {"data":[{"id":"3062214000179868001","Partner_Allocation":[{"Open":100,"Close":100,"Delivery":100,"Partner":"3062214000006944015"},{"id":"3062214000179868002","_delete":null},{"id":"3062214000179868003","_delete":null}]}],"trigger":["workflow"]}
- Error updating allocation: Error: Zoho API error: 400 {"data":[{"code":"INVALID_DATA","details":{"api_name":"Partner","json_path":"$.data[0].Partner_Allocation[0].Partner"},"message":"invalid data","status":"error"}]}
- at zohoRequest (lib/zoho.ts:155:12)
- at async doTheUpsert (lib/services/SalesOrderService.ts:355:12)
- at async createSalesOrder (lib/services/SalesOrderService.ts:369:6)
- at async createEngagement (components/accounts/actions/engagements.ts:114:24)
- 153 |
- 154 | if (!res.ok) {
- > 155 | throw new Error(`Zoho API error: ${res.status} ${await res.text()}`)
- | ^
- 156 | }
- 157 |
- 158 | logRateLimitHeaders(res)
I get the ID that I am sending from the Users that come back from a `/users?type=AllUsers` call with a `Partner` role -
{
"id": "3062214000006944015",
"name": "",
"email": "user@example.com",
"role": {
"name": "Partner",
"id": "3062214000000026008"
}
},
Thanks for any guidance from the community!
Best,
-e