I have been trying to update the selected option in a custom field based on the instructions provided here 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?