type Asana = {
token: string;
};
/**
* Update a custom field
* A specific, existing custom field can be updated by making a PUT request on the URL for that custom field.
*/
export async function main(
auth: Asana,
custom_field_gid: string,
opt_pretty: string | undefined,
opt_fields: string | undefined,
body: {
data?: (({ gid?: string; resource_type?: string; [k: string]: unknown } & {
date_value?: { date?: string; date_time?: string; [k: string]: unknown };
display_value?: string;
enabled?: boolean;
enum_options?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & {
color?: string;
enabled?: boolean;
name?: string;
[k: string]: unknown;
})[];
enum_value?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & {
color?: string;
enabled?: boolean;
name?: string;
[k: string]: unknown;
}) & { [k: string]: unknown };
multi_enum_values?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & {
color?: string;
enabled?: boolean;
name?: string;
[k: string]: unknown;
})[];
name?: string;
number_value?: number;
resource_subtype?:
| "text"
| "enum"
| "multi_enum"
| "number"
| "date"
| "people";
text_value?: string;
type?: "text" | "enum" | "multi_enum" | "number";
[k: string]: unknown;
}) & {
asana_created_field?:
| "a_v_requirements"
| "account_name"
| "actionable"
| "align_shipping_link"
| "align_status"
| "allotted_time"
| "appointment"
| "approval_stage"
| "approved"
| "article_series"
| "board_committee"
| "browser"
| "campaign_audience"
| "campaign_project_status"
| "campaign_regions"
| "channel_primary"
| "client_topic_type"
| "complete_by"
| "contact"
| "contact_email_address"
| "content_channels"
| "content_channels_needed"
| "content_stage"
| "content_type"
| "contract"
| "contract_status"
| "cost"
| "creation_stage"
| "creative_channel"
| "creative_needed"
| "creative_needs"
| "data_sensitivity"
| "deal_size"
| "delivery_appt"
| "delivery_appt_date"
| "department"
| "department_responsible"
| "design_request_needed"
| "design_request_type"
| "discussion_category"
| "do_this_task"
| "editorial_content_status"
| "editorial_content_tag"
| "editorial_content_type"
| "effort"
| "effort_level"
| "est_completion_date"
| "estimated_time"
| "estimated_value"
| "expected_cost"
| "external_steps_needed"
| "favorite_idea"
| "feedback_type"
| "financial"
| "funding_amount"
| "grant_application_process"
| "hiring_candidate_status"
| "idea_status"
| "ids_link"
| "ids_patient_link"
| "implementation_stage"
| "insurance"
| "interview_area"
| "interview_question_score"
| "itero_scan_link"
| "job_s_applied_to"
| "lab"
| "launch_status"
| "lead_status"
| "localization_language"
| "localization_market_team"
| "localization_status"
| "meeting_minutes"
| "meeting_needed"
| "minutes"
| "mrr"
| "must_localize"
| "name_of_foundation"
| "need_to_follow_up"
| "next_appointment"
| "next_steps_sales"
| "num_people"
| "number_of_user_reports"
| "office_location"
| "onboarding_activity"
| "owner"
| "participants_needed"
| "patient_date_of_birth"
| "patient_email"
| "patient_phone"
| "patient_status"
| "phone_number"
| "planning_category"
| "point_of_contact"
| "position"
| "post_format"
| "prescription"
| "priority"
| "priority_level"
| "product"
| "product_stage"
| "progress"
| "project_size"
| "project_status"
| "proposed_budget"
| "publish_status"
| "reason_for_scan"
| "referral"
| "request_type"
| "research_status"
| "responsible_department"
| "responsible_team"
| "risk_assessment_status"
| "room_name"
| "sales_counterpart"
| "sentiment"
| "shipping_link"
| "social_channels"
| "stage"
| "status"
| "status_design"
| "status_of_initiative"
| "system_setup"
| "task_progress"
| "team"
| "team_marketing"
| "team_responsible"
| "time_it_takes_to_complete_tasks"
| "timeframe"
| "treatment_type"
| "type_work_requests_it"
| "use_agency"
| "user_name"
| "vendor_category"
| "vendor_type"
| "word_count";
currency_code?: string;
custom_label?: string;
custom_label_position?: "prefix" | "suffix";
description?: string;
enum_options?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & {
color?: string;
enabled?: boolean;
name?: string;
[k: string]: unknown;
})[];
format?: "currency" | "identifier" | "percentage" | "custom" | "none";
has_notifications_enabled?: boolean;
is_global_to_workspace?: boolean;
precision?: number;
[k: string]: unknown;
}) & { people_value?: string[]; workspace: string; [k: string]: unknown };
[k: string]: unknown;
}
) {
const url = new URL(
`https://app.asana.com/api/1.0/custom_fields/${custom_field_gid}`
);
for (const [k, v] of [
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + 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 418 days ago