# Need some help with updating custom\_field.multi\_enum\_values

**URL:** <https://forum.asana.com/t/need-some-help-with-updating-custom-field-multi-enum-values/589774>\
**Category:** API & Developers\
**Created:** [31 October 2023 18:35 UTC](https://forum.asana.com/t/need-some-help-with-updating-custom-field-multi-enum-values/589774 "2023-10-31T18:35:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy\_Pilipovic](https://luna1.co/8d76cd.png) [@Andy\_Pilipovic](https://forum.asana.com/u/Andy_Pilipovic)\
**Post date:** [31 October 2023 18:35 UTC](https://forum.asana.com/t/need-some-help-with-updating-custom-field-multi-enum-values/589774/1 "2023-10-31T18:35:37Z")

</div>

I’ve been working with Asana’s API in Python, I’ve ran into a problem that I cannot figure out.

I am trying to update a Custom field on a task, the field is a multi enum value.  
I am passing the custom field gid and the multi enum value gid however I cannot get it to update.  
I’ve tried using the API explorer and tried to update it from there however I’m still not getting any good outcomes.

This is what the code looks like, any ideas where I’m going wrong?

task\_gid\_input = (‘1205636205887937’)  
task\_gid = (‘1205837604911113’)

input = client.tasks.get\_task(task\_gid\_input,  
opt\_fields = {‘custom\_fields.display\_value’}, opt\_pretty=True)  
print(input)

print(‘done’)

stages\_to\_check\_for = [‘4. Site Inspection needed’, ‘5. Site Inspection Scheduled’, ‘6. Site Inspection Completed’, ‘07. 2nd Site Inspection Scheduled’, ‘15. Engineering in Progress’, ‘16. Pending HOA’, ‘17. Plan Ready’, ‘18. Engineering Revisions’, ‘20. Ready for Permit’, ‘21. Pending Permit’, ‘22. Permit Received’, ‘23. HI/MPU in Progress’, ‘24. Installation in Progress’, ‘25. Installation Complete’, ‘26. Final Inspection Pending’, ‘27. Final Inspection Received’, ‘30. Pending PTO’, ‘31. PTO Received’, ‘33. Places in Service’, ‘Lost’]

# Extract the ‘display\_value’ from custom fields

custom\_fields = input.get(‘custom\_fields’, )  
display\_value = None

for field in custom\_fields:  
if field.get(‘display\_value’) in stages\_to\_check\_for:  
display\_value = field.get(‘display\_value’)  
break

stages = {  
“4. Site Inspection needed”: “1205176507759394”,  
“5. Site Inspection Scheduled”: “1205176507759395”,  
“6. Site Inspection Completed”: “1205176507759396”,  
“07.2nd Site Inspection Scheduled”: “1205176507759397”,  
“15. Engineering in Progress”: “1205176507759398”,  
“16. Pending HOA”: “1205176507759399”,  
"17. Plan Ready ": “1205176507759400”,  
“18. Engineering Revisions”: “1205176507759401”,  
“20. Ready for Permit”: “1205176507759402”,  
“21. Pending Permit”: “1205176507759403”,  
“22. Permit Received”: “1205176507759404”,  
“23. HI/MPU in Progress”: “1205176507759405”,  
"24. Installation in Progress ": “1205176507759406”,  
"25. Installation Complete ": “1205176507759407”,  
"26. Final Inspection Pending ": “1205176507759408”,  
“27. Final Inspection Received”: “1205176507759409”,  
"30. Pending PTO ": “1205176507759410”,  
"31. PTO Received ": “1205176507759411”,  
“33. Places in Service”: “1205176507759412”,  
“Lost”: “1205176507759413”}

# Print the ‘display\_value’

if display\_value is not None:  
print(f"The display value for task GID {task\_gid\_input} is: {display\_value}“)  
else:  
print(f"No ‘display\_value’ found for task GID {task\_gid\_input}”)

display\_value\_output = stages[display\_value]

print(display\_value\_output)

#result = client.tasks.update\_task(task\_gid,  
#params={“1205176507759393”: ‘“’ + (display\_value\_output) + ‘”’}, opt\_pretty=True)

custom\_field\_gid = ‘1205176507759393’  
custom\_field\_value = display\_value\_output

result = client.tasks.update\_task(  
task\_gid,  
params={custom\_field\_gid: custom\_field\_value},  
opt\_pretty=True  
)

print(‘done’)

---

<div class="post-metadata">

**Author:** ![John\_Vu](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/john_vu/32/97235_2.png) [@John\_Vu](https://forum.asana.com/u/John_Vu)\
**Post date:** [31 October 2023 18:48 UTC](https://forum.asana.com/t/need-some-help-with-updating-custom-field-multi-enum-values/589774/2 "2023-10-31T18:48:10Z")

</div>

Hi @Andy_Pilipovic,

Here’s how you update a multi-select custom field with python ([v3.2.2](https://pypi.org/project/asana/3.2.2/))

```plaintext
import asana
from pprint import pprint

client = asana.Client.access_token("<YOUR_PERSONAL_ACCESS_TOKEN>")
task_gid = "<YOUR_TASK_GID>"
custom_field_gid = "<YOUR_MULTI_SELECT_CUSTOM_FIELD_GID>"
multi_select_enum_value = "<YOUR_MULTI_SELECT_ENUM_VALUE_GID>"

result = client.tasks.update_task(
    task_gid, 
    {'custom_fields': {custom_field_gid: multi_select_enum_value}}
)
pprint(result)

```

**NOTE:** you should not be providing the `display_value` as the value for updating the value of a multi-select custom field. Instead provide the enum\_gid of the value of the multi-select\_enum option. You can get information about the available enum options for your multi-select custom field by asking for `custom_fields.enum_options ` in your [Get a task](https://developers.asana.com/reference/gettask) API call.

---

<div class="post-metadata">

**Author:** ![Andy\_Pilipovic](https://luna1.co/8d76cd.png) [@Andy\_Pilipovic](https://forum.asana.com/u/Andy_Pilipovic)\
**Post date:** [31 October 2023 18:52 UTC](https://forum.asana.com/t/need-some-help-with-updating-custom-field-multi-enum-values/589774/3 "2023-10-31T18:52:46Z")

</div>

@John_Vu you are a gift \<3

That worked. I was also able to post while providing the display\_value as it holds the gid of the multi enum field that it finds in the dict.

Thanks once again, this has been pestering me for the past 24 hours 😃

---

<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:** [7 November 2023 18:53 UTC](https://forum.asana.com/t/need-some-help-with-updating-custom-field-multi-enum-values/589774/4 "2023-11-07T18:53:35Z")

</div>

Closed on 7 November 2023 18:53 UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
