Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Trello API: How do I accurately get the value of a Custom Field?

Jake February 9, 2022

Hello :)

First time posting, thank you for any help & guidance. 

I'm attempting to store custom field values using GET /1/cards/{id}/customFieldItems 

My problem is that the order of the custom fields response is inconsistent, meaning my bracket notation to access the value is unreliable as the fields do not appear in the same position. 

value = response[0]['value']['number'];

Please see screenshot which shows the response of 4 separate cards in a list. 

Screen Shot 2022-02-09 at 7.24.28 pm.png

Can someone please provide some knowledge as to why this happens and any options I may have to get around it?

Thank you very much!

2 answers

0 votes
Felix
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 9, 2022

Hey @Jake - this is a bit unfortunate, and we should probably be sorting the field items before returning them.

Nevertheless, you will have to rely on the idCustomField value to tell you which custom field the custom field item value refers.

Basically, you have the "customFields" which can be retrieved from /1/boards/:id/customFields, which is the definition of the fields (name, type, position, id).

That definition (the "customField") is what the customFieldItem.idCustomField refers to, and what you'll need to use to match up which customField the customFieldItem provides a value for.

Sidenote: there's also an Atlassian Developer Community (https://community.developer.atlassian.com/), where API questions might be answered more quickly.

 

Felix

Jake February 14, 2022

Thank you very much Felix, I'll try to implement this and report back :)

 

I appreciate the response! 

 

Jake

0 votes
milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 9, 2022

@Jake 

Would get by custom_field by name a better bet ...not sure this would work...you can try it

next(cf for cf in card_cf_list if cf['name'] == req_field_name)

(note...did not test code)

Jake February 14, 2022

Thanks @milynnus I'll let you know how i go :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events