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

Add label on existing cards based on text

Ken K August 12, 2021

I would like to find existing cards that contain a particular word in the description (ie. triads, scales) and assign a label based on the word found - so cards with the word "triad" are assigned the "orange triad" label. 

Seems easy enough... search/ filter based on a word, then add the label to the card - however I can't figure out how to do this in Butler.

I am able to use Butler to do this for new cards, however not sure how to do it on existing cards. Thanks in advance for you help. 

1 answer

1 accepted

0 votes
Answer accepted
David Bakkers
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.
August 12, 2021

Hello @Ken K 

No, you can't do that with Butler. If you create a rule with a Card Content trigger where the description contains certain text, on the page you will see the following warning message:

Note: This will only trigger when you create or modify a card's name or description. It will not work retro-actively for existing cards on the board, or for other members on the board (unless they create and enable their own rule).

This sort of advanced action might be possible with Benkobot.

Ken K August 12, 2021

Yes, thank you for the reply @David Bakkers

I have seen that message before and wondered if there was a workaround. I've never heard of Benkobot, but I will check it out. I appreciate your help. 

David Bakkers
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.
August 12, 2021

No problem. If you feel the answer was correct, please mark it as such, so that the next reader of the topic knows that.

PS. The community member who can answer most questions about BenkoBot's capabilities is @Iain Dooley 

Iain Dooley
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 12, 2021

@David Bakkers thanks :)

@Ken K this would do it in BenkoBot you can save it as an "ad hoc" function and then edit the word to run it for each time, you'll also need to update your board name:

https://gist.github.com/iaindooley/fd22d1a675199e2ba5d70021503923d9

Ken K August 12, 2021

Thanks for the note @Iain Dooley 

I don't know much about benkobot yet but your code looks pretty straight forward. I put the board name "Lesson Log" in the quotes.  

I added the code in the AdHoc entry box and clicked Run. It goes for a bit, but returns without actually updating any cards.

Can you explain how the code knows which label to apply? Is there something else I might be overlooking (I've never used this). 

I was expecting to see the cards  that have "Triad" in them with a new Triad label. 

Sorry for the total newbie experience. I appreciate your help.

Iain Dooley
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 12, 2021

@Ken K looks like I didn't lower case the search ;) try this:

https://gist.github.com/iaindooley/fd22d1a675199e2ba5d70021503923d9

Ken K August 12, 2021

Thanks @Iain Dooley -  I totally appreciate your help... 

Awesome - it worked! You rock!!

I noticed it created a new colorless label. Is there a way in the code to assign a color to the label?  Or is there a way to assign an existing label?

If it's in the docs, just tell me and I'll dig in (just figured you'd know off the top of your head). 

Great stuff!! Thanks again!! Saved me hours!!!

Iain Dooley
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 12, 2021

@Ken K yeah it just defaults to no colour, you can easily edit the labels to add colours and later it will re-use the same one.

Of course it just uses the Trello API under the hood so you could craft the API call you want yourself to add a label with a colour, eventually it will make it into the Trellinator library ;)

Note that you get 10 free execution minutes per month on the free plan (which you're automatically subscribed to).

Scheduled adhoc functions, library functions and global command groups coming soon to a bot near you!

Iain Dooley
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 12, 2021

@Ken K there are also examples of "listeners" and other adhoc code snippets on this board, as well as a developer crash course and we will keep adding stuff here:

https://trello.com/b/IoHmhz5c/benkobot-community-board

Ken K August 12, 2021

@Iain Dooley Thank you so much. This was exactly what I needed. My board just became 10x more valuable to me!

I was able to edit the label easily - it just threw me at first because I didn't realize the label had been applied. Killer stuff. 

I will definitely check out the resources and try to get my head around the whole benkobot interface. Incredibly helpful and I'm very grateful Iain.  

Like Iain Dooley likes this
Ken K August 13, 2021

@Iain Dooley 

Sorry to bother you Iain... I tried running the same code using an existing label.

Rec'd this error in the console...

https://api.trello.com/1/cards/6107939cfe2a253a3162e1d2/idLabels with status code 400:

Should I be able to use an existing label? Perhaps I misunderstood your comment about "re-using the same one".

My intent is to apply the same label on cards containing different text strings (ie. Triads, 351, 513, etc) all getting the same label. To do this, I'm running the script multiple times (with new search strings). It chokes when trying to use the same label name.

Thanks in advance!

Iain Dooley
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 25, 2021

@Ken K hey sorry for the delayed response. 400 is a "bad request" error, did you receive any further text or information in the logs?

You should def be able to use existing labels... 

Ken K September 5, 2021

Hi Iain - finally getting back to this - thanks for the reply. I still get the error but the script is definitely working. There's not much else than what I wrote above. I wonder if I'm not letting it finish and that's why I'm getting the error. 

Either way things are great - thanks again!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events