Asana / python-asana

Official Python client library for the Asana API v1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tasks.find_by_project: Obtain custom fields's VALUE as part of opt_fields

drzraf opened this issue · comments

client.tasks.find_by_project(gid, opt_fields='custom_fields.name, custom_fields.value')

Expected:

"custom_fields": [
      {
        "gid": "4907421210123456",
        "name": "Estimated hours",
        "value": "6"
      }
]

Actual:

"custom_fields": [
      {
        "gid": "4907421210123456",
        "name": "Estimated hours"
      }
]

What's the way to obtain the actual values from tasks custom fields (in the context of multi-tasks API calls)?

Hey @drzraf,

The schema looks like ( taken from https://developers.asana.com/docs/custom-field )

"data": {
    "gid": "12345",
    "resource_type": "custom_field",
    "currency_code": "EUR",
    "custom_label": "gold pieces",
    "custom_label_position": "suffix",
    "description": "Development team priority",
    "enabled": true,
    "enum_options": [
      {
        "gid": "12345",
        "resource_type": "enum_option",
        "color": "blue",
        "enabled": true,
        "name": "Low"
      }
    ],
    "enum_value": {
      "gid": "12345",
      "resource_type": "enum_option",
      "color": "blue",
      "enabled": true,
      "name": "Low"
    },
    "format": "custom",
    "has_notifications_enabled": true,
    "is_global_to_workspace": true,
    "name": "Status",
    "number_value": 5.2,
    "precision": 2,
    "resource_subtype": "text",
    "text_value": "Some Value",
    "type": "text"
  }

So you'll need to opt into "number_value", "text_value" or "enum_value" to get the values.

Let me know if this doesn't help!