Edits history of script submission #21851 for ' Mass update (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Mass update
     *
     */
    export async function main(
      auth: Zoho,
      _module: string,
      body: {
        ids?: string[];
        owner?: { id?: string };
        notify?: false | true;
        related_modules?: { id?: string; api_name?: string }[];
      },
    ) {
      const url = new URL(
        `https://zohoapis.com/crm/v8/${_module}/actions/change_owner`,
      );
    
      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