sarumont / py-trello

Python API wrapper around Trello's API
BSD 3-Clause "New" or "Revised" License
941 stars 328 forks source link

requesting help - get custom field value #288

Open mals14 opened 5 years ago

mals14 commented 5 years ago

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.

jdmry commented 5 years ago

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

mals14 commented 4 years ago

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