0

Bulk Update Custom Module

by
Published Oct 17, 2025

To update existing custom module records in bulk, use the argument below

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Bulk Update Custom Module
7
 * To update existing custom module records in bulk, use the argument below
8
 */
9
export async function main(
10
  auth: Zoho,
11
  module_name: string,
12
  organization_id: string | undefined,
13
  body: {
14
    cf_debt_amount?: number;
15
    module_record_id?: string;
16
    record_name: string;
17
  },
18
) {
19
  const url = new URL(`https://www.zohoapis.com/books/v3/${module_name}`);
20
  for (const [k, v] of [["organization_id", organization_id]]) {
21
    if (v !== undefined && v !== "" && k !== undefined) {
22
      url.searchParams.append(k, v);
23
    }
24
  }
25
  const response = await fetch(url, {
26
    method: "PUT",
27
    headers: {
28
      "Content-Type": "application/json",
29
      Authorization: "Zoho-oauthtoken " + auth.token,
30
    },
31
    body: JSON.stringify(body),
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.json();
38
}
39