0

Create map dependency

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
 * Create map dependency
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  layout_id: string,
12
  _module: string | undefined,
13
  body: {
14
    map_dependency?: {
15
      parent?: { api_name?: string; id?: string };
16
      child?: { api_name?: string; id?: string };
17
      pick_list_values?: {
18
        id?: string;
19
        actual_value?: string;
20
        display_value?: string;
21
        maps?: {
22
          id?: string;
23
          actual_value?: string;
24
          display_value?: string;
25
          _delete?: false | true;
26
        }[];
27
      }[];
28
      internal?: false | true;
29
      active?: false | true;
30
      id?: string;
31
      source?: number;
32
      category?: number;
33
      sub_module?: { api_name?: string; id?: string };
34
    }[];
35
  },
36
) {
37
  const url = new URL(
38
    `https://zohoapis.com/crm/v8/settings/layouts/${layout_id}/map_dependency`,
39
  );
40
  for (const [k, v] of [["module", _module]]) {
41
    if (v !== undefined && v !== "" && k !== undefined) {
42
      url.searchParams.append(k, v);
43
    }
44
  }
45
  const response = await fetch(url, {
46
    method: "POST",
47
    headers: {
48
      "Content-Type": "application/json",
49
      Authorization: "Zoho-oauthtoken " + auth.token,
50
    },
51
    body: JSON.stringify(body),
52
  });
53
  if (!response.ok) {
54
    const text = await response.text();
55
    throw new Error(`${response.status} ${text}`);
56
  }
57
  return await response.json();
58
}
59