0

Update global picklist

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 global picklist
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  id: string,
12
  body: {
13
    global_picklists: {
14
      display_label: string;
15
      created_time: string;
16
      modified_time: string;
17
      id: string;
18
      api_name: string;
19
      actual_label: string;
20
      description: string;
21
      modified_by: { name: string; id: string; email?: string };
22
      created_by: { name: string; id: string; email?: string };
23
      presence: false | true;
24
      pick_list_values_sorted_lexically: false | true;
25
      pick_list_values: {
26
        actual_value: string;
27
        type: "unused" | "used";
28
        id: string;
29
        sequence_number: number;
30
        display_value: string;
31
      }[];
32
    }[];
33
  },
34
) {
35
  const url = new URL(
36
    `https://zohoapis.com/crm/v8/settings/global_picklists/${id}`,
37
  );
38

39
  const response = await fetch(url, {
40
    method: "PATCH",
41
    headers: {
42
      "Content-Type": "application/json",
43
      Authorization: "Zoho-oauthtoken " + auth.token,
44
    },
45
    body: JSON.stringify(body),
46
  });
47
  if (!response.ok) {
48
    const text = await response.text();
49
    throw new Error(`${response.status} ${text}`);
50
  }
51
  return await response.json();
52
}
53