Get from a Task the display value of a specific custom field in python

Hi everyone,
I would like to be able to extract from a task the display value of a specific custom field using the client.tasks.get_task or similar function. Is there anyone who has tried the same operation who can help me?

Yes sure. Were you able to get the task name via the API first for example? And then we can look at getting the custom field value.

Yes sure, with the code client.tasks.get_tasks_for_project(project_gid , opt_fields=(‘gid’,‘name’,‘custom_fields.display_value’)) I can take all the display value of the custom fields I have in the project. To take the display value of just one, let say the display value of the custom field that have the gid value of ‘120000000400’, how could I do it?

Can you post here what’s the answer of your request for “all the display value”. Because I am guessing then this is just about navigating to the right key in the JSOn object. (you should use backquotes around pieces of code here)

Of course, the answer I get is this:
[{‘gid’: ‘1200913167718688’, ‘display_value’: ‘INC000000378437’}, {‘gid’: ‘1200021989215050’, ‘display_value’: ‘Low’}, {‘gid’: ‘1201666369886716’, ‘display_value’: ‘S’}, {‘gid’: ‘1201714807390390’, ‘display_value’: ‘Infrastructure Event’}, {‘gid’: ‘1200913167695984’, ‘display_value’: ‘PROD’}, {‘gid’: ‘1200206779684032’, ‘display_value’: None}, {‘gid’: ‘1201721054872156’, ‘display_value’: None}, {‘gid’: ‘1200036027496913’, ‘display_value’: None}, {‘gid’: ‘1199159319996409’, ‘display_value’: None}, {‘gid’: ‘1200913167713458’, ‘display_value’: None}, {‘gid’: ‘1200280194438723’, ‘display_value’: None}, {‘gid’: ‘1200207215908783’, ‘display_value’: None}]
What I would like to display is only the custom field that has gid: ‘1200913167718688’ which in this case refers to the displayed value of INC000000378437 .

Thank you very much for your help,


Said custom field is the first one in your array, you need to filter the array to extract only what you need. Which language are you working with?


And why not filter the array you receive in Python to find the entry you are looking for?

How? I have a number of tasks from which I need to extract this field, all have different types of Custom Field because they come from different projects

Either you make several search requests to find each task individually, or they all have something in common and you can run a single search to find them at once. Once you have the entire tasks object given by Asana, you can look at custom fields value.

Sorry I’m probably not understanding. I extract from a project all the tasks with their custom field values and custom field gid. For each task I will have a very long json, I wanted to ask if it was possible to make a precise extraction of the value on a custom field gid that I know all the tasks have.

No, not possible to ask for just one particular custom field, you have to get them all and find the appropriate one within your own code.

1 Like

Thanks Phil for clarifying.