0

List all Credit Notes

by
Published Oct 17, 2025

List all the Credit Notes.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * List all Credit Notes
7
 * List all the Credit Notes.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  creditnote_number: string | undefined,
13
  date: string | undefined,
14
  status: string | undefined,
15
  total: string | undefined,
16
  reference_number: string | undefined,
17
  customer_name: string | undefined,
18
  item_name: string | undefined,
19
  customer_id: string | undefined,
20
  item_description: string | undefined,
21
  item_id: string | undefined,
22
  line_item_id: string | undefined,
23
  tax_id: string | undefined,
24
  filter_by: string | undefined,
25
  search_text: string | undefined,
26
  sort_column: string | undefined,
27
) {
28
  const url = new URL(`https://www.zohoapis.com/inventory/v1/creditnotes`);
29
  for (const [k, v] of [
30
    ["organization_id", organization_id],
31
    ["creditnote_number", creditnote_number],
32
    ["date", date],
33
    ["status", status],
34
    ["total", total],
35
    ["reference_number", reference_number],
36
    ["customer_name", customer_name],
37
    ["item_name", item_name],
38
    ["customer_id", customer_id],
39
    ["item_description", item_description],
40
    ["item_id", item_id],
41
    ["line_item_id", line_item_id],
42
    ["tax_id", tax_id],
43
    ["filter_by", filter_by],
44
    ["search_text", search_text],
45
    ["sort_column", sort_column],
46
  ]) {
47
    if (v !== undefined && v !== "" && k !== undefined) {
48
      url.searchParams.append(k, v);
49
    }
50
  }
51
  const response = await fetch(url, {
52
    method: "GET",
53
    headers: {
54
      Authorization: "Zoho-oauthtoken " + auth.token,
55
    },
56
    body: undefined,
57
  });
58
  if (!response.ok) {
59
    const text = await response.text();
60
    throw new Error(`${response.status} ${text}`);
61
  }
62
  return await response.json();
63
}
64