0

Update records

by
Published Oct 17, 2025
Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Update records
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  module_api_name: string,
12
  body: {
13
    data?: {
14
      id?: string;
15
      Created_By?: { name: string; id: string; email?: string };
16
      Created_Time?: string;
17
      Modified_By?: { name: string; id: string; email?: string };
18
      Modified_Time?: string;
19
      Tag?: {
20
        name: string;
21
        color_code:
22
          | "#57B1FD"
23
          | "#879BFC"
24
          | "#658BA8"
25
          | "#FD87BD"
26
          | "#969696"
27
          | "#F48435"
28
          | "#1DB9B4"
29
          | "#E7A826"
30
          | "#63C57E"
31
          | "#F17574"
32
          | "#D297EE"
33
          | "#A8C026"
34
          | "#B88562";
35
        created_time: string;
36
        modified_time: string;
37
        modified_by: { name: string; id: string; email?: string };
38
        created_by: { name: string; id: string; email?: string };
39
        id: string;
40
      }[];
41
      name?: string;
42
    }[];
43
    trigger?: string[];
44
    process?: string[];
45
    duplicate_check_fields?: string[];
46
    wf_trigger?: string;
47
    lar_id?: string;
48
  },
49
  X_EXTERNAL?: string,
50
) {
51
  const url = new URL(`https://zohoapis.com/crm/v8/${module_api_name}`);
52

53
  const response = await fetch(url, {
54
    method: "PUT",
55
    headers: {
56
      ...(X_EXTERNAL ? { "X-EXTERNAL": X_EXTERNAL } : {}),
57
      "Content-Type": "application/json",
58
      Authorization: "Zoho-oauthtoken " + auth.token,
59
    },
60
    body: JSON.stringify(body),
61
  });
62
  if (!response.ok) {
63
    const text = await response.text();
64
    throw new Error(`${response.status} ${text}`);
65
  }
66
  return await response.json();
67
}
68