Hi,
I am trying to fetch the tasks using API for my team members from a project which has custom fields. I am able to fetch the normal fields using the “opt_fields” in search API.
For example, I am executing this Curl statement:
curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer xxxx' 'https://app.asana.com/api/1.0/workspaces/xxxxx/tasks/search?opt_fields=name,completed,due_on&assignee.any=username&due_on.before=2020-08-29&due_on.after=2020-08-23'
And, if I run this, I will get three field values - name completed or not and due date without any issue.
But how do I get the custom fields value in output JSON along with the standard field values?
Thanks
Suyash
Hi @Suyash_Jain, welcome to the forum !
You will get the custom fields values, by adding this to your “opt_fields” parameter:
custom_fields.enum_value.gid,custom_fields.number_value,custom_fields.text_value
But, using that, you will get values, but not the “name” of the custom field.
And, for the enum_value, again, you get an ID, not the “text” of the enum…
Names of custom fields and text of “enums” can be loaded once from the project and/or workspace definition.
When you query your projects list, asks for “custom_field_settings” opt_field to load the definition. I suggest to not query custom_field_settings from the “search” task, because you will get tons of duplicate data in return.
3 Likes
I came across this thread after reading through Custom Fields At A Project Level - Not Task - #31 by Kiltie_Colavita . The issue we are facing, which seems to remain an open question, is how do we “utilize” the custom fields at the Project Level? Within Asana I do not see how to sort/filter/search projects that have a project-level-custom-field tag – and I am not having any luck within the API in retrieving custom fields at the Project Level. These are “visible” within a portfolio and when opening a project directly by viewing Project Details – however is there a way to retrieve all the data shown within Project Details via API to build out the community requested functionality if not available within Asana e.g. the project level custom fields etc.? See attached.
Please note, the focus is on the custom fields, there is a known API call to portfolios however there is not a direct tie back to the project…my question is more focused on the custom fields use/access at the project level, I had included the portfolio item as well simply because it is shown within the same view ![:slight_smile: :slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)
Hi @Antonio_Felicetta,
If you call this endpoint and ask to include custom fields:
GET /projects/{project gid}?opt_fields=custom_fields
Asana will return you the custom fields set on that project and their values.
Excellent, tested and confirmed… is there another call that will also provide the Portfolio shown in the picture… Ideally something like this:
GET /projects/{project gid}?opt_fields=portfolios,custom_fields
??
@Antonio_Felicetta,
Not from the project; a project record doesn’t have any idea what portfolios it’s in.
You have to come at that data from the portfolio side. This endpoint will return a list of the projects in a portfolio:
https://developers.asana.com/docs/get-portfolio-items
Ahhh… I also tried opt_expand in hopes it was there, alas not. I will plan for a couple calls then join the portfolios element back to the project w/custom fields. Thank you.
1 Like