Edits history of script submission #21244 for ' Create map dependency (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Create map dependency
     *
     */
    export async function main(
      auth: Zoho,
      layout_id: string,
      _module: string | undefined,
      body: {
        map_dependency?: {
          parent?: { api_name?: string; id?: string };
          child?: { api_name?: string; id?: string };
          pick_list_values?: {
            id?: string;
            actual_value?: string;
            display_value?: string;
            maps?: {
              id?: string;
              actual_value?: string;
              display_value?: string;
              _delete?: false | true;
            }[];
          }[];
          internal?: false | true;
          active?: false | true;
          id?: string;
          source?: number;
          category?: number;
          sub_module?: { api_name?: string; id?: string };
        }[];
      },
    ) {
      const url = new URL(
        `https://zohoapis.com/crm/v8/settings/layouts/${layout_id}/map_dependency`,
      );
      for (const [k, v] of [["module", _module]]) {
        if (v !== undefined && v !== "" && k !== undefined) {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Zoho-oauthtoken " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago