Edits history of script submission #21463 for ' Get Record Detail View (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
      baseUrl: string;
    };
    /**
     * Get Record Detail View
     * This API fetches the data displayed in the detail view of a record, which is identified by the ID value passed. This API will not fetch the records displayed in the related data blocks of the detail view.
     */
    export async function main(
      auth: Zoho,
      account_owner_name: string,
      app_link_name: string,
      report_link_name: string,
      record_ID: string,
      field_config: string | undefined,
      fields: string | undefined,
    ) {
      const url = new URL(
        `${auth.baseUrl}/creator/v2.1/data/${account_owner_name}/${app_link_name}/report/${report_link_name}/${record_ID}`,
      );
      for (const [k, v] of [
        ["field_config", field_config],
        ["fields", fields],
      ]) {
        if (v !== undefined && v !== "" && k !== undefined) {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Zoho-oauthtoken " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago