Edits history of script submission #21932 for ' Share record (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Share record
     *
     */
    export async function main(
      auth: Zoho,
      module_api_name: string,
      record_id: string,
      body: {
        share: {
          shared_with?: {
            country?: string;
            language?: string;
            microsoft?: false | true;
            $shift_effective_from?: {};
            id?: string;
            state?: string;
            fax?: string;
            country_locale?: string;
            zip?: string;
            created_time?: string;
            time_format?: "HH:mm" | "hh:mm a";
            offset?: number;
            imap_status?: false | true;
            image_link?: string;
            ezuid?: string;
            profile?: { name: string; id: string };
            role?: { name: string; id: string };
            created_by?: { name: string; id: string; email?: string };
            full_name?: string;
            zuid?: string;
            phone?: string;
            dob?: string;
            status?: string;
            customize_info?: {
              notes_desc: {};
              show_right_panel: {};
              bc_view: {};
              unpin_recent_item: {};
              show_home: false | true;
              show_detail_view: false | true;
            };
            city?: string;
            signature?: string;
            sort_order_preference__s?: string;
            category?: string;
            date_format?: "MMM d, yyyy";
            confirm?: false | true;
            decimal_separator?: "Comma" | "Period";
            number_separator?: "Space";
            time_zone?: {};
            last_name?: string;
            mobile?: string;
            $current_shift?: { name: string; id: string };
            Reporting_To?: { name: string; id: string; email?: string };
            Currency?: string;
            $next_shift?: { name: string; id: string };
            Modified_Time?: string;
            website?: string;
            status_reason__s?: string;
            email?: string;
            first_name?: string;
            sandboxDeveloper?: false | true;
            alias?: string;
            street?: string;
            Modified_By?: {
              name: string;
              id: string;
              last_name: string;
              first_name: string;
            };
            Isonline?: false | true;
            locale?: string;
            name_format__s?:
              | "Salutation,First Name,Last Name"
              | "Saluation,Last Name,First Name"
              | "First Name,Last Name,Saluation";
            personal_account?: false | true;
            default_tab_group?: string;
            theme?: {
              normal_tab: { font_color: "#FFFFFF"; background: "#222222" };
              selected_tab: { font_color: "#FFFFFF"; background: "#222222" };
              new_background: string;
              background: "#F3F0EB";
              screen: "fixed";
              type: string;
            };
            ntc_notification_type?: number[];
            ntc_enabled?: false | true;
            rtl_enabled?: false | true;
            telephony_enabled?: false | true;
            sort_order_preference?: string;
          };
          share_related_records: false | true;
          shared_through: {
            module: { name?: string; api_name?: string; id?: string };
            id: string;
            entity_name: string;
            name?: string;
          };
          shared_time: string;
          permission: string;
          shared_by: {
            country?: string;
            language?: string;
            microsoft?: false | true;
            $shift_effective_from?: {};
            id?: string;
            state?: string;
            fax?: string;
            country_locale?: string;
            zip?: string;
            created_time?: string;
            time_format?: "HH:mm" | "hh:mm a";
            offset?: number;
            imap_status?: false | true;
            image_link?: string;
            ezuid?: string;
            profile?: { name: string; id: string };
            role?: { name: string; id: string };
            created_by?: { name: string; id: string; email?: string };
            full_name?: string;
            zuid?: string;
            phone?: string;
            dob?: string;
            status?: string;
            customize_info?: {
              notes_desc: {};
              show_right_panel: {};
              bc_view: {};
              unpin_recent_item: {};
              show_home: false | true;
              show_detail_view: false | true;
            };
            city?: string;
            signature?: string;
            sort_order_preference__s?: string;
            category?: string;
            date_format?: "MMM d, yyyy";
            confirm?: false | true;
            decimal_separator?: "Comma" | "Period";
            number_separator?: "Space";
            time_zone?: {};
            last_name?: string;
            mobile?: string;
            $current_shift?: { name: string; id: string };
            Reporting_To?: { name: string; id: string; email?: string };
            Currency?: string;
            $next_shift?: { name: string; id: string };
            Modified_Time?: string;
            website?: string;
            status_reason__s?: string;
            email?: string;
            first_name?: string;
            sandboxDeveloper?: false | true;
            alias?: string;
            street?: string;
            Modified_By?: {
              name: string;
              id: string;
              last_name: string;
              first_name: string;
            };
            Isonline?: false | true;
            locale?: string;
            name_format__s?:
              | "Salutation,First Name,Last Name"
              | "Saluation,Last Name,First Name"
              | "First Name,Last Name,Saluation";
            personal_account?: false | true;
            default_tab_group?: string;
            theme?: {
              normal_tab: { font_color: "#FFFFFF"; background: "#222222" };
              selected_tab: { font_color: "#FFFFFF"; background: "#222222" };
              new_background: string;
              background: "#F3F0EB";
              screen: "fixed";
              type: string;
            };
            ntc_notification_type?: number[];
            ntc_enabled?: false | true;
            rtl_enabled?: false | true;
            telephony_enabled?: false | true;
            sort_order_preference?: string;
          };
          user: {
            country?: string;
            language?: string;
            microsoft?: false | true;
            $shift_effective_from?: {};
            id?: string;
            state?: string;
            fax?: string;
            country_locale?: string;
            zip?: string;
            created_time?: string;
            time_format?: "HH:mm" | "hh:mm a";
            offset?: number;
            imap_status?: false | true;
            image_link?: string;
            ezuid?: string;
            profile?: { name: string; id: string };
            role?: { name: string; id: string };
            created_by?: { name: string; id: string; email?: string };
            full_name?: string;
            zuid?: string;
            phone?: string;
            dob?: string;
            status?: string;
            customize_info?: {
              notes_desc: {};
              show_right_panel: {};
              bc_view: {};
              unpin_recent_item: {};
              show_home: false | true;
              show_detail_view: false | true;
            };
            city?: string;
            signature?: string;
            sort_order_preference__s?: string;
            category?: string;
            date_format?: "MMM d, yyyy";
            confirm?: false | true;
            decimal_separator?: "Comma" | "Period";
            number_separator?: "Space";
            time_zone?: {};
            last_name?: string;
            mobile?: string;
            $current_shift?: { name: string; id: string };
            Reporting_To?: { name: string; id: string; email?: string };
            Currency?: string;
            $next_shift?: { name: string; id: string };
            Modified_Time?: string;
            website?: string;
            status_reason__s?: string;
            email?: string;
            first_name?: string;
            sandboxDeveloper?: false | true;
            alias?: string;
            street?: string;
            Modified_By?: {
              name: string;
              id: string;
              last_name: string;
              first_name: string;
            };
            Isonline?: false | true;
            locale?: string;
            name_format__s?:
              | "Salutation,First Name,Last Name"
              | "Saluation,Last Name,First Name"
              | "First Name,Last Name,Saluation";
            personal_account?: false | true;
            default_tab_group?: string;
            theme?: {
              normal_tab: { font_color: "#FFFFFF"; background: "#222222" };
              selected_tab: { font_color: "#FFFFFF"; background: "#222222" };
              new_background: string;
              background: "#F3F0EB";
              screen: "fixed";
              type: string;
            };
            ntc_notification_type?: number[];
            ntc_enabled?: false | true;
            rtl_enabled?: false | true;
            telephony_enabled?: false | true;
            sort_order_preference?: string;
          };
          type?: "private" | "public";
        }[];
        notify_on_completion?: false | true;
        notify?: false | true;
      },
    ) {
      const url = new URL(
        `https://zohoapis.com/crm/v8/${module_api_name}/${record_id}/actions/share`,
      );
    
      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