0

Pin unpin fields

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
 * Pin unpin fields
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  id: string,
12
  _module: string | undefined,
13
) {
14
  const url = new URL(
15
    `https://zohoapis.com/crm/v8/settings/custom_views/${id}/actions/pin_unpin_fields`,
16
  );
17
  for (const [k, v] of [["module", _module]]) {
18
    if (v !== undefined && v !== "" && k !== undefined) {
19
      url.searchParams.append(k, v);
20
    }
21
  }
22
  const response = await fetch(url, {
23
    method: "PUT",
24
    headers: {
25
      "Content-Type": "application/json",
26
      Authorization: "Zoho-oauthtoken " + auth.token,
27
    },
28
    body: undefined,
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.json();
35
}
36