Edits history of script submission #21241 for ' Create global picklist (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Create global picklist
     *
     */
    export async function main(
      auth: Zoho,
      body: {
        global_picklists: {
          display_label: string;
          created_time: string;
          modified_time: string;
          id: string;
          api_name: string;
          actual_label: string;
          description: string;
          modified_by: { name: string; id: string; email?: string };
          created_by: { name: string; id: string; email?: string };
          presence: false | true;
          pick_list_values_sorted_lexically: false | true;
          pick_list_values: {
            actual_value: string;
            type: "unused" | "used";
            id: string;
            sequence_number: number;
            display_value: string;
          }[];
        }[];
      },
    ) {
      const url = new URL(`https://zohoapis.com/crm/v8/settings/global_picklists`);
    
      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