Is there any way on api to get values of dropdown type custom fields?
Asked by Turan Gurler:

Hello, we have a power-up app on trello; however, we cannot get values of custom fields that are with type of "dropdown". Is there any way to retrieve?

API URL: GET [https://api.trello.com/1/board/607eb929ee33c047e810692f/cards?customFieldItems=true\&fields=name\&](https://api.trello.com/1/board/607eb929ee33c047e810692f/cards?customFieldItems=true&fields=name&)key=**{key}** \&token=**{token}**

Response:

![Screen Shot 2021-08-06 at 00.02.31.png](https://community.atlassian.com/t5/image/serverpage/image-id/154827i964ABC901973C586/image-size/large?v=v2&px=999 "Screen Shot 2021-08-06 at 00.02.31.png")


Answers:
author: David Bakkers
body: Hello [@Turan Gurler](/t5/user/viewprofilepage/user-id/1201071)

In the response from the REST API, for the dropdown custom fields, it will only tell you the ID of the option that's been selected for that field:
> {  
> "id": "60cd9a5dc324113a527ad8ff",  
> **"idValue": "60cd97c3199236728d9cf992"** , *\<- The id of the option selected*   
> **"idCustomField": "60cd9792d094da669588de05",** *\<- The id of the field*   
> "idModel": "607e32a184fead458a199e07",  
> "modelType": "card"  
> }

To translate that ID value back into what that option contains (IE the text and the color) you have to query the [Get a Custom Field](https://developer.atlassian.com/cloud/trello/rest/api-group-customfields/#api-customfields-id-get) endpoint using the ID of that dropdown custom field:

```
GET https://api.trello.com/1/customFields/60cd9792d094da669588de05?key={key}&token={token}
```

...and you will get back something like the following:
> {  
> **"id": "60cd9792d094da669588de05",** *\<- The id of the field*   
> "idModel": "602786e91c69d30e45a9ccd8",  
> "modelType": "board",  
> "fieldGroup": "bba6783271ae2131251b190534817d1ccadd217b2267540b434cbdaf417866c9",  
> "display": {  
> "cardFront": true  
> },  
> "name": "Dropdown choices",  
> "pos": 49152,  
> "options": \[  
> **{**   
> **"id": "60cd97c3199236728d9cf992",** *\<- The id of the option*   
> **"idCustomField": "60cd9792d094da669588de05",** *\<- The id of the field, again*   
> **"value": {**   
> **"text": "Green option** " *\<- The text for that option*   
> **},**   
> **"color": "green",** *\<- The color for that option*   
> **"pos": 16384** *\<- The position of that option within the field (the order)*   
> **},**   
> {  
> "id": "60cd97c791d7b954b63dbaeb",  
> "idCustomField": "60cd9792d094da669588de05",  
> "value": {  
> "text": "Red option"  
> },  
> "color": "red",  
> "pos": 32768  
> }  
> \],  
> "type": "list",  
> "limits": {  
> "customFieldOptions": {  
> "perField": {  
> "status": "ok",  
> "disableAt": 50,  
> "warnAt": 45  
> }  
> }  
> },  
> "isSuggestedField": false  
> }

From these two pieces of data, it's now known that the dropdown custom field called *'Dropdown choices'* on a particular card has been set to the value *'Green option'* and that option has the color *'green'*.

The reason for this two-step approach is that the options available for the dropdown custom fields are stored at the board level, not the card level, so you have to query at *the next level up*, so to speak, to find what those options are, then correlate them to which one has been chosen for a particular card.

comments: author: Turan Gurler
body: Hi David,

That will be a great solution! Thanks for the answer.


author: ManniStudio
body: Hi David,

First off thank you so much for your answer. I'm facing the same Puzzle.

I went through your example and learned a lot. I was able to complete it and get a list of all Options for my Custom field.

But how can I tell which option was selected? The JSON doesn't reveal which option was selected by the user (that I can find).

++**Example**++:

I have custom field called: "First name", setup as a dropdown, and contains 4 options:

*First Name*

James

John Paul

Robert

John \<\<\<\<\<==== Selected

If I select Option #4 "John" how do I perform a GET that tells me that this option was selected?

User UI:

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/215405iE2DE38C370E7072C/image-size/large?v=v2&px=999 "image.png")

My Get call using the ID for my Custom Field "First Name":

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/215406i0505A20AD08FEA94/image-size/large?v=v2&px=999 "image.png")

JSON: Info on each option:

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/215412i94FAC3E973FE18F0/image-size/large?v=v2&px=999 "image.png")

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/215413iE06F4DBD6C11276B/image-size/large?v=v2&px=999 "image.png")

Apologies if I missed something in your example, I'm still Green with REST calls.

cheers,

Damon


author: David Bakkers
body: Hello [@ManniStudio](/t5/user/viewprofilepage/user-id/4989529)

The answer is in the OP's original question. You need to query the [Get Custom Field Items for a Card](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-customfielditems-get) endpoint, which will tell you the IDs of any options that have been set per custom field per card.

**Note**. If this endpoint returns an empty set, it means no options have been set for any custom fields on that card.

For example, I have a board with custom drop-down field called '*Dropdown choices* ' and it has four choices (I can discover the field and its options from the [Get Custom Fields for a Board](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-customfields-get) endpoint).

On one particular card, that custom field has been set to the choice '*Purple option*':

![Card.png](https://community.atlassian.com/t5/image/serverpage/image-id/215429i9A3C7AE3FBE29456/image-size/large?v=v2&px=999 "Card.png")

I lookup the custom field items for that card:

```
GET https://api.trello.com/1/cards/631ed7381a8cfb00e091c317/customFieldItems?key=blah&token=blah
```

And the response tells me:
> \[  
> {  
> "id": "631ed7381a8cfb00e091c317",  
> **"idValue": "60ce91cf104a13124295ec0e** ", *\<-- id of the option selected*   
> **"idCustomField": "60cd9792d094da669588de05"** , *\<-- id of the custom field*   
> "idModel": "62c545eaaa69773929397646",  
> "modelType": "card"  
> }  
> \]

<br />

So, I then just compare the ID of the option selected for that custom field for that card with the knowledge I already know about that custom field via either the [Get a Custom Field](https://developer.atlassian.com/cloud/trello/rest/api-group-customfields/#api-customfields-id-get) endpoint or the [Get Custom Fields for a Board](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-customfields-get) endpoint to reverse 'translate' the option ID back to the text content for that option.


author: Rodrigo
body: I never used API, but I do access the JSON file through Power BI. I believe the problem here is that you're accessing the "Cards" section of the database. This will bring the value set for the cards.

Instead, you should be going for the "customFields" portion of the database. Through that, you will be able to get all the data related to Custom Fields per se, like which fields you havem their ids, types, and 'Options', which is what you are looking for.

comments: author: Rodrigo
body: Maybe this will help?

![untitled.png](https://community.atlassian.com/t5/image/serverpage/image-id/154842iE9591A9D297D9E93/image-size/large?v=v2&px=999 "untitled.png")


author: Turan Gurler
body: Well, thanks for the reply but i'm looking for the API solution.


author: Rodrigo
body: **Turan**


Tags: api

custom-field

select-list