How do I get the values for custom field dropdowns on a card?
When I query for custom fields and they're dropdowns, this is what I get
"customFieldItems": [{
"id": "5fa07bddf31c3b69d32d7564",
"idValue": "5fa079eb3c04d6016ef994e3",
"idCustomField": "5fa079eb3c04d6016ef994e2",
"idModel": "5fa07a2956c88531d9d125be",
"modelType": "card"
},
I'm guessing I need to do something with idValue, but I have no clue how. The API docs don't really go into detail on dropdown custom fields.
This is one with a custom field date, and it has a clear value.
{
"id": "5fa07be5ad5b1f1ef10b73fe",
"value": {
"date": "2020-10-22T16:00:00.000Z"
},
"idCustomField": "5fa073a5eedccb1a273b7db2",
"idModel": "5fa07a2956c88531d9d125be",
"modelType": "card"
}
I don't understand why the difference.
You're right, that's not entirely clear! I think it has to do with making Dropdown values flexible if they're changed at a later date. You'll need to cross-reference the idValue with the "id" of that option from the dropdown.
You can get both using a request like this:
GET https://api.trello.com/1/cards/{cardID}?key=...&token=...&customFieldItems=true&customFields=true
Then you can compare like this:
"customFieldItems": [
{
"id": "5fb404d66fe67d43442e640c",
"idValue": "5fb404ce868b9d54b61e9958",
"idCustomField": "5fb404c715857a51e549b2dc",
"idModel": "5fa07e5ce3ee8a01a53f18a1",
"modelType": "card"
},
And checking that against the "options" in the customFields response:
{
"id": "5fb404ce868b9d54b61e9958",
"idCustomField": "5fb404c715857a51e549b2dc",
"value": {
"text": "drop3"
},
"color": "none",
"pos": 49152
}
Once you find the ID that matches the idValue, the text attribute will tell you the actual value of that Dropdown that's shown to the user.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.