# Update the value/chosen option of enum custom field in a task through client.tasks.update

**URL:** <https://forum.asana.com/t/update-the-value-chosen-option-of-enum-custom-field-in-a-task-through-client-tasks-update/700920>\
**Category:** API & Developers\
**Tags:** custom-fields, tasks\
**Created:** [10 February 2024 18:59 UTC](https://forum.asana.com/t/update-the-value-chosen-option-of-enum-custom-field-in-a-task-through-client-tasks-update/700920 "2024-02-10T18:59:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leonardo\_Ibarra](https://luna1.co/8d76cd.png) [@Leonardo\_Ibarra](https://forum.asana.com/u/Leonardo_Ibarra)\
**Post date:** [10 February 2024 18:59 UTC](https://forum.asana.com/t/update-the-value-chosen-option-of-enum-custom-field-in-a-task-through-client-tasks-update/700920/1 "2024-02-10T18:59:48Z")

</div>

I have been trying to update the selected option in a custom field based on the instructions provided [here](https://forum.asana.com/t/updating-custom-field-values-dropdowns/281357) but even though the API returns the task data as expected, it does not set the option in the custom field.

My custom field is named ‘Due date format’ and it has two options: ‘Dynamic’ and ‘Fixed’.  
I confirmed that i successfully fetched the GID of the custom fields and its options, as well as the GID and data for the task.

I’m using this code:

> # print(custom\_field.get(‘enum\_options’)) # Got the ID of each option through this line.
> 
> # Dynamic type enum\_option GID: 1206558670504134, Fixed: 1206558670504135
> 
> # Prepare the data payload to update the custom field
> 
> due\_date\_format\_id = ‘1206558670504133’  
> dynamic\_option\_gid = ‘1206558670504134’  
> data = {  
> ‘data’: {  
> ‘custom\_fields’: {  
> due\_date\_format\_id: dynamic\_option\_gid # ‘gid’ of ‘Due date format’: ‘gid’ of ‘Dynamic’  
> }  
> }  
> }
> 
> # Make the PUT request to update the task with the default enum value
> 
> response = client.tasks.update(task\_GID, data)
> 
> # Find the custom field in the response
> 
> custom\_field\_response = next(  
> (field for field in response[‘custom\_fields’] if field[‘gid’] == due\_date\_format\_id),  
> None  
> )
> 
> # Check if the custom field was found and print relevant information
> 
> if custom\_field\_response:  
> print(f"Custom field ‘{custom\_field\_response[‘name’]}’ with GID {due\_date\_format\_id} found in the response.“)  
> if custom\_field\_response[‘enum\_value’]:  
> print(f"Value: {custom\_field\_response[‘enum\_value’][‘name’]}”)  
> else:  
> print(“Value not set.”) # This is the final case, i.e. there’s no enum\_value set after running the code.  
> else:  
> print(f"No custom field found with GID {due\_date\_format\_id} in the response.")

My code successfully identifies the task and custom field, but the set option is not updated. Can you help identify why this is happening?

---

<div class="post-metadata">

**Author:** ![Stephen\_Li](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/stephen_li/32/279555_2.png) [@Stephen\_Li](https://forum.asana.com/u/Stephen_Li)\
**Post date:** [10 February 2024 21:45 UTC](https://forum.asana.com/t/update-the-value-chosen-option-of-enum-custom-field-in-a-task-through-client-tasks-update/700920/2 "2024-02-10T21:45:46Z")

</div>

Hi @Leonardo_Ibarra ,

Welcome to the forum! Sorry, I’m having a hard time parsing your code. Are you using one of the [client libraries](https://developers.asana.com/docs/client-libraries)?

To confirm, you are trying to update an enum field on an existing task, right? Generally speaking, your process would be something like:

1. Get the gid for target task
2. Get the gid for your enum field and the gid for any enum\_options
3. Call [this endpoint](https://developers.asana.com/reference/updatetask) with a PUT method and a body something like:

```auto
let body = {
    "data": {
        "custom_fields": {
            "field_gid": "enum_option_gid"
        }
    }
};

```

This is generally the same process I think you were following while still encountering errors, so a few questions:

1. How are you confirming that the option didn’t update? In the return for the function, are you specifying custom\_fields in the opts parameter?
2. Are you passing in the key:value within a custom\_fields object (I think calling GET tasks returns the fields as an array of objects)?
3. Are you making sure that both the key and value (field and option gid) are strings and not numbers?

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/system/32/276370_2.png) [@system](https://forum.asana.com/u/system)\
**Post date:** [30 May 2025 19:00 UTC](https://forum.asana.com/t/update-the-value-chosen-option-of-enum-custom-field-in-a-task-through-client-tasks-update/700920/3 "2025-05-30T19:00:25Z")

</div>

Closed on 30 May 2025 19:00 UTC


