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

Get current board Id in custom powerup

Anders October 14, 2020

Hi

 

I have a power up that use the trello api to iterate a list's cards. But now I have to pass the board id, get the list by name and then iterate the cards.

 

I want to be able to do this without having to pass the boards id but instead do this on the current board where the power up is used.

 

Since it's an iframe I can't get the url from the trello board and compare to the url of the boards that I get in the api. How do I get current boards Id?

 

How can I create input boxes on my cards similar to CustomFields? 

 

Thanks

1 answer

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.
October 15, 2020

@Anders  I built several custom power ups.  Once the user authorise his/account, the board id should be available to the JS that is associated with your power up. Because I do best with python, most of my business logic at the server side is via AJAX to some callbackurl that runs some py-Trello programs and my power ups are built on top of a Low-code platform. 

This custom power up iterate through a list and move cards a round .

Anders October 15, 2020

Ok. And how do I retrieve that id?

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.
October 15, 2020

@Anders not sure how to explain it better. 

See the partial code block below. This is for the card button to convert checklist to cards. The t.get('id') .then function(card) {....etc creates Card object from which the $(card.id) is obtained.

I do not need the board here but I think the board id variable would be $(card.board_id)

var cardSuperCLRun = function(t){

return t.get('member', 'private', 'token') .then(function(token) {
    if (!token) {
     console.log('No token found')
   }
return t.card('id') .then (function(card) {
  return t.popup({
    title: 'Superhero Checklist - Run',
    url: `/?action=run&card_id=${card.id}&token=${token}`,
    height: 200,
   });
 }) 

So once the card_id is passed to the callbackurl aka an endpoint. 

launch_card = client.get_card(󰀂v.107-card_id󰀂)

cardTrelloList = launch_card.trello_list

card_lookup = {}

for xcard in cardTrelloList.list_cards():
card_lookup[xcard.name] = xcard
card_lookup[xcard.url] = xcard
name_url = '''{} {}'''.format(xcard.name, xcard.url)
card_lookup[name_url] = xcard

trello_board = client.get_board(launch_card.board_id)

I can the board_id as should in the sample code above once I get the card object launch_card

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events