py-trello icon indicating copy to clipboard operation
py-trello copied to clipboard

requesting help - get custom field value

Open mals14 opened this issue 6 years ago • 2 comments

I am trying to get value of a custom field for a card that I obtain using

all cards = board.get_cards({'filter' : 'open', 'fields' : 'all'})
for card in all_cards:
  # "Completed" is a checkbox on the board and may or may not be checked on the card in question
  is_complete = card.get_custom_field_by_name('Completed')
  if is_complete:
    print('This card is complete')

However, the above code does not seem to capture when Completed check box is checked on the card.

If instead, I do,

card.fetch()
# and then
print(card._customFields[0].value)

Then it prints the value as True. However, in this case there is only one checkbox on the card that is checked. If another one is checked, I will have to run a loop on this list. Which does not make sense to do because you have already enabled that capability in your python library.

Thanks for your help.

mals14 avatar Jun 06 '19 01:06 mals14

is_complete will be the customfield object, you need to do something like: is_complete = card.get_custom_field_by_name('Completed').value that should give you your boolean

jdmry avatar Jul 23 '19 13:07 jdmry

Thank you @jdmry. I think my Github alert did not work and I read this comment now.

mals14 avatar Sep 01 '19 21:09 mals14