PowerUp handling card events

Within a javascript PowerUp is it possible to handle certain card events? Specifically I am thinking about when a card gets added or removed from a list (moved between lists essentially). Ideally there is a "capability" or something similar which would allow for my JS function to be called when that "state change" happens. 

It seems like this would be possible through the web hooks API, but I was trying to keep this solution clean and small so only the PowerUp client.js would be needed (vs needing a dynamic server ready to accept web hook POST requests, etc).

Thanks!

 

1 answer

0 votes
Bentley Cook Atlassian Team Dec 18, 2017

Hey Jay,

There isn't currently a way to achieve what you want to do purely within a Power-Up. You're correct that this would require using the webhooks API which requires keeping a separate service up. Depending on the size and scope of what you want to do, you might be able to use a serverless architecture as a workaround.

Can you go into more detail on what you want to be able to do once you've been notified of a chance? We've talked a bit about how best to implement webhook-like capabilities within the Power-Ups platform. Would love to have more examples of usage to contribute to the conversation.

What I am trying to do is when a card enters certain lists that we have on our board, to mark a timestamp. Then we want to use a card-badges power up to show the "age" of the card for when it entered into the list. Unfortunately it seems like I need a web hook to capture that transition state and timestamp the card. However - I can't create/update pluginData via the backend webhook code (via the REST API). 

Ideally I would stamp the pluginData via the REST API, then the card-badges powerUp JS code would read that data and update the "age" the card entered that particular list. Basically by looking at the stamped time (from the web hook and stored in pluginData) and comparing it to the current date. 

Also, it seems like in the JS plugin code when trying to access pluginData it makes a REST call (thus firing off a ton of GETs for all cards on the board). Is there anyway to tell the plugin code to fetch the pluginData upfront, so it doesn't have to fire off all these calls?

To get around these various API limitations, I ended up creating a "file" from my web hook when the card enters one of the lists we care about. Then the plugin JS code for the card-badges looks for my special url file and extracts the date out of the file_name. Its a real hack. :)

@Jay Danielian Thanks for sharing. There is another workaround that might be a bit cleaner. At the point in time that a card is moved Trello will re-call some of the capabilities to see if anything needs to be updated. One of those capabilities is card-badges. In the callback function for card-badges, you could check to see if the card is in the list that you care about, if it is and it hasn't been there before, then you use t.set on the card to set the timestamp. You can tell whether a card is already in the list if it has a value already set for the timestamp and then you'll also want to make sure you remove the timestamp if the card is being moving out of the list. But all of this should be do-able within the card-badges capability.

Regardless, I've added your use-case to our card tracking developer requests around full API access to pluginData. Thanks for the input!

As for all of the REST calls, are you making use of t.get in your card-badges capability? That will generate a separate call for each card. Right now there isn't a way to get around this, and it sounds like you're using the client library as expected. Are you experiencing delays because of network latency?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Dec 10, 2018 in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

196 views 5 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you