Edits history of script submission #22059 for ' Update blue print (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Update blue print
     *
     */
    export async function main(
      auth: Zoho,
      module_api_name: string,
      record_id: string,
      body: {
        blueprint: {
          transition_id: string;
          data: {
            id?: string;
            Created_By?: { name: string; id: string; email?: string };
            Created_Time?: string;
            Modified_By?: { name: string; id: string; email?: string };
            Modified_Time?: string;
            Tag?: {
              name: string;
              color_code:
                | "#57B1FD"
                | "#879BFC"
                | "#658BA8"
                | "#FD87BD"
                | "#969696"
                | "#F48435"
                | "#1DB9B4"
                | "#E7A826"
                | "#63C57E"
                | "#F17574"
                | "#D297EE"
                | "#A8C026"
                | "#B88562";
              created_time: string;
              modified_time: string;
              modified_by: { name: string; id: string; email?: string };
              created_by: { name: string; id: string; email?: string };
              id: string;
            }[];
            name?: string;
          };
          process_info: {
            field_id: number;
            is_continuous: false | true;
            api_name: string;
            continuous: false | true;
            field_label: string;
            name: string;
            column_name: string;
            field_value: string;
            id: string;
            field_name: string;
            escalation?: { days?: number; status?: string };
            current_picklist?: {
              colour_code?: string;
              id?: string;
              value?: string;
            };
          };
          transitions: {
            type?: string;
            execution_time?: string;
            sequence?: number;
            next_transitions: {
              id: string;
              name: string;
              criteria_matched?: false | true;
              type?: string;
            }[];
            parent_transition?: {};
            percent_partial_save: number;
            data: {
              id?: string;
              Created_By?: { name: string; id: string; email?: string };
              Created_Time?: string;
              Modified_By?: { name: string; id: string; email?: string };
              Modified_Time?: string;
              Tag?: {
                name: string;
                color_code:
                  | "#57B1FD"
                  | "#879BFC"
                  | "#658BA8"
                  | "#FD87BD"
                  | "#969696"
                  | "#F48435"
                  | "#1DB9B4"
                  | "#E7A826"
                  | "#63C57E"
                  | "#F17574"
                  | "#D297EE"
                  | "#A8C026"
                  | "#B88562";
                created_time: string;
                modified_time: string;
                modified_by: { name: string; id: string; email?: string };
                created_by: { name: string; id: string; email?: string };
                id: string;
              }[];
              name?: string;
            };
            next_field_value: string;
            text_color_code: string;
            name: string;
            criteria_matched: false | true;
            id: number;
            fields: {
              external?: {
                show: false | true;
                type: string;
                allow_multiple_config?: false | true;
              };
              display_type?: -1 | 2;
              filterable?: false | true;
              pick_list_values_sorted_lexically?: false | true;
              sortable?: false | true;
              ui_type?: number;
              private?: {
                restricted: false | true;
                type: string;
                export: false | true;
              };
              system_mandatory: false | true;
              webhook: false | true;
              json_type: string;
              crypt: {
                mode: string;
                column: string;
                table: string;
                status: number;
              };
              field_label: string;
              tooltip: { name: string; value: string };
              created_source: string;
              layouts: { id: string; name: string };
              field_read_only: false | true;
              content: string;
              display_label: string;
              validation_rule: string;
              read_only: false | true;
              association_details: {
                lookup_field: { id: string; name: string };
                related_field: { id: string; name: string };
              };
              multi_module_lookup: {
                display_label: string;
                api_name: string;
                modules: {
                  api_name: string;
                  id: string;
                  module_name?: string;
                  module?: string;
                }[];
              };
              currency: { rounding_option: string; precision: number };
              id: string;
              custom_field: false | true;
              lookup: {
                display_label: string;
                api_name: string;
                module: string;
                id: string;
              };
              convert_mapping: {};
              visible: false | true;
              length: number;
              column_name: string;
              _type: string;
              view_type: {
                view: false | true;
                edit: false | true;
                create: false | true;
                quick_create: false | true;
              };
              transition_sequence: number;
              api_name: string;
              unique: { casesensitive?: string };
              history_tracking: false | true;
              data_type: string;
              formula: { return_type: string; expression: number };
              decimal_place: string;
              multiselectlookup: {
                display_label: string;
                linking_module: string;
                lookup_apiname: string;
                api_name: string;
                connectedlookup_apiname: string;
                id: string;
              };
              pick_list_values: {
                colour_code: string;
                actual_value: string;
                type: "unused" | "used";
                id: string;
                sequence_number: number;
                display_value: string;
                reference_value?: string;
                deal_category?: string;
                probability?: number;
                forecast_category?: { id?: string; name?: string };
                expected_data_type?: string;
                sys_ref_name?: string;
                forecast_type?: string;
                maps?: { api_name?: string; pick_list_values?: {}[] }[];
                _delete?: false | true;
                show_value?: false | true;
              }[];
              auto_number: { prefix: string; suffix: string; start_number: number };
              personality_name: string;
              mandatory: false | true;
              quick_sequence_number: number;
              profiles?: { id?: string; name?: string; permission_type?: string }[];
            }[];
            color_code: string;
            criteria_message: string;
          }[];
        }[];
      },
    ) {
      const url = new URL(
        `https://zohoapis.com/crm/v8/${module_api_name}/${record_id}/actions/blueprint`,
      );
    
      const response = await fetch(url, {
        method: "PUT",
        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