How can I get a list of all labels used in one or more lists on a board?
Asked by jhewgley:

I would like to be able to get a unique list of all the labels that are used on the cards in a list or perhaps across several specified lists. I have some javascript that will do this but it is kind of clunky because I have to paste it into the Developer Tools console and run it from there. This is something I need to do every day. Is there a cleaner way to do this?

Here is my use case:

Every day, I review cards across multiple lists on one board and move the cards I need to address in the current day to a single list for the day. All off my cards have labels indicating the project they belong to or an activity label such as "email" or "phone." Once I have the cards for the day moved to the list of todos for the day, I want to generate a unique list of the labels used on those cards so I can then go and schedule a timebox on my calendar for each label. I then address the cards throughout the day according to the calendar timebox indicated by their labels. I've found that timeboxing my activities helps me get a lot more done.


Answers:
author: Oliver S
body: Hi jhewgley,

There is an API Endpoint you could use to get all labels used on a board (so at the board level): <https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-labels-get>

Another way to approach this would be to think about whether the information you need could be gathered using a [Scheduled Automation](https://support.atlassian.com/trello/docs/creating-and-managing-butler-commands/#Scheduled-automations), part of Trello's built in automation features.

For example, you could create something like:

*"Everyday at 8am, create a report in variable 'labelsUsed', filter all cards that have the blue label and yellow label, and send an email notification to test@test.com with the cards in 'labelsUsed'.*

Example:

![Screenshot 2023-07-25 at 1.32.07 pm.png](https://community.atlassian.com/t5/image/serverpage/image-id/270868iB0203F863CA93FFF/image-dimensions/439x357?v=v2 "Screenshot 2023-07-25 at 1.32.07 pm.png")

This would send an email through to the specified address with cards matching the filters you've set. You would likely need to adjust / tailor it to your specific needs, but this could help as a starting point to take the manual work out of it. :)

comments: author: jhewgley
body: Thanks for the suggestion of using scheduled automation. I will look into that and see if I can get it to provide me a list of labels for a particular list.

I am also updating my original question above to better describe my use case.


author: Oliver S
body: No worries! :) Based on your updated description, I tested a very simple example where I looked for all cards that had a yellow label assigned and generated an email report:

![Screenshot 2023-07-26 at 11.15.38 am.png](https://community.atlassian.com/t5/image/serverpage/image-id/271162i1C9031ED49EBCFF1/image-size/large?v=v2&px=999 "Screenshot 2023-07-26 at 11.15.38 am.png")

Here's how it looks in Automation:

![Screenshot 2023-07-26 at 11.17.55 am.png](https://community.atlassian.com/t5/image/serverpage/image-id/271164i83A7C4D6DB76CBA0/image-size/large?v=v2&px=999 "Screenshot 2023-07-26 at 11.17.55 am.png")

You'll notice in this example I make use of the "using pattern". This allows you to draw upon Automation variables to choose how the information displays in the email report. You'll notice there are quite a lot of different fields you can use to format the report: <https://support.atlassian.com/trello/docs/butler-variables/>.

Keen to hear how you get along! :)


author: jhewgley
body: Thanks for continuing to help me find a solution. Your latest example makes good use of automation variables but it still doesn't produce a unique list of labels (label names). If there was a {listlabelnames} automation variable, I bet it would give me what I want. But there is no such automation variable (documented).

Essentially what I want is a unique list of label names that are used on a given list.

The icing on the cake would be able to get a unique list of label names used across one or more lists on a board (but not all lists on the board!). The following JavaScript, when run from the console in the browser's developer tools, produces what I need across the 3 specified lists on my board. It is just very clunky to execute that way. What would be amazing would be if Trello had the ability to save javascript snippets with a board and be able to execute with a custom list action. Since you can't do that (I don't think), I'm looking for another way to generate what I need.

![JSSample.png](https://community.atlassian.com/t5/image/serverpage/image-id/271171iA14A4229E4DF94FC/image-size/large?v=v2&px=999 "JSSample.png")


author: Oliver S
body: Appreciate the additional context and feedback!

Makes more sense what you're trying to do, and sounds like based on the way you're currently achieving it - it could be a lot simpler.

I've gone ahead and filed a feature request to provide this additional level of detail through an additional variable or through a custom list action. While I can't promise an ETA, I have passed on your feedback to the team.

One other thing I should note - in the more recent example above, the labels I used didn't actually have a name to them - just coloured labels. You might be able to adjust it a bit - as there is a filter you can use for a specific list. That said, I realise it may still be a bit limited for what you're after.