Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,295,939
Community Members
 
Community Events
165
Community Groups

Is there any way on api to get values of dropdown type custom fields?

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&key={key}&token={token}

Response:

Screen Shot 2021-08-06 at 00.02.31.png

3 answers

1 accepted

Hello @Turan Gurler 

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 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.

Hi David,

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

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.

Maybe this will help?

untitled.png

Well, thanks for the reply but i'm looking for the API solution. 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Trello

Taco Tuesday: New years' resolutions with Trello

Congratulations to @Laura Holton , our latest winner of Taco Tuesday! And thanks to @Kristján Geir Mathiesen for sharing the picture of Taco having fun with his new friend  B...

2,321 views 28 40
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you