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

How to shorten a variable in automation?

Torsten Berger September 7, 2023

Hi there,

in an automation I use {cardname} and additional info for a new card title. Can I shorten the given text? Usually in APIs there is some functionality like for example {cardname|5} for the first 5 letters …

Cheers,
Torsten

1 answer

0 votes
Dreamsuite Mike
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2023

HI @Torsten Berger 

It is worth familiarising yourself with the pattern matching functionality available in Trello:

https://support.atlassian.com/trello/docs/pattern-matching-and-wildcards/ 

using variables like {matchedtext}, {textbeforematch} and {textaftermatch} really help here...

Trello also supports RegEx so you can create more complex examples with that

 

For example, if you wanted to truncate the card name to 5 characters, the automation would be:

when the name of a card contains "regex:/^.{0,5}/", rename the card to {matchedtext}

Torsten Berger September 7, 2023

@Dreamsuite Mike thanks for the hint! But how do get a "when" condition inside my procedure? 

My (fake) example (real thing is more complex):

- starts with click to a card button (let's say here on card "Very important Card")

→ find a special template card

→ copy that template card to list XYZ

→ rename title of template to "NEW: {triggercardname}"

→ result is a card "NEW: Very important Card"

But as title I only want "New: {first 10 letters from triggercardname}..." (so here "NEW: Very impor...").

 

I understand regex etc. but for that I would need some "when/if/..." inside my routine and I don't see that. If I just add a find (with cascade → find card contains "regex:/^.{0,5}/"), all my cards on the board would get changed.

Torsten Berger September 13, 2023

I solved it somehow with a workaround:

→ I created a new rule like "If a specific label is added to a card with name [here I added the RegEx that finds a very specific prefix and gives me the (shortened) part back that I need to rename the later card]" – then rename this card to [here I use the part from the RegEx]"

→ Then I changed the button I described earlier to rename the new card with a specific prefix to the whole name, also I add in the end the specific label, which then triggers the new rule.

So it creates first the card with the whole (long) name (like before) and is then automatically shortened by the new rule. The label is needed to trigger the RegEx-Search to get the part of the whole name. The prefix (in combination with the RegEx) makes sure that not a "normal" card is renamed when the label ist used by accident. I also added a comment with old name - new name, so if someone does trigger it by accident, it can be found and be reversed.

It would be so much easier if Trello would just support some basic template commands, like {triggercardname|5} would give back the first 5 letters of the name.  :-)

Cheers,
Torsten

Dreamsuite Mike
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 16, 2023

Hi @Torsten Berger 

 

Sorry for the delay in replying, I have been travelling.

Screenshot 2023-09-16 145705.png

This is the area where you can use "when the name/description of a card contains..."

 

Regarding the variables, there is almost no chance of Trello making any changes to this so if you do want to do more in that area, it is worth learning around regex.  It opens up so many possibilities.

Take a look at this article for guidance:

https://community.atlassian.com/t5/Trello-articles/Mikes-Trello-Tips-Automation-to-truncate-a-numeric-custom-field/ba-p/2385182 

In that article @Krimo Khermane suggestion of using ChatGPT to formulate the regex query is a really useful tip 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events