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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,757
Community Members
 
Community Events
176
Community Groups

Automation to add labels based on text present in summary or description

Looking for advice on streamlining an automation.

I'd like to have a list of values (applications/components/common pain points). For each issue created, i'd like to check the Summary and Description against that list, and for each match (eg summary OR description contains WiFi and Printing, to then add a label for each match. So this example would add 2 labels - 'WiFi' and 'Printing'.

 

I'm trying to condense this from a whole bunch of If/Else blocks... would appreciate any thoughts

2 answers

1 accepted

0 votes
Answer accepted

Hi @Daniel Helmstedt -- Welcome to the Atlassian Community!

One way to do this would be to create your list of check values in a created variable, separated by commas.  And then use advanced branching to iterate over them.  For example

  • trigger: issue created:
  • action: create variable with your list
  • advanced branch: splitting the created variable into a list
    • condition: check if the value is found (from the branch variable)
    • action: add the label
    • action: re-fetch the trigger issue

Another way to do this is with a regular expression, copying the source field (e.g. Summary)  to a created variable, and then replacing anything not in your search list of terms with an empty string.  Then parse the results into a smart value list and add all of the labels at one time using an advanced JSON edit expression.

Kind regards,
Bill

Thanks Bill! That's a much simpler flow than I was working on!

How would you go about checking the smart value against both Summary and Description - can that be done in one step? 

Cheers!

Hi, Daniel.

If you mean the second thing I suggested, I meant removing the non-matching expressions (i.e. to your tests) with a RegEx and then using the remainder to create the list for the labels.  This is certainly going to take a bit of experimentation to get correct; the specifics of your search strings may not make this approach viable.

The first approach I noted should be easy to try and get working...giving you time to experiment with the second approach.  That would only require use of advanced compare conditions with "contains" or use of the text searching functions.

Regarding your ask about checking Summary and Description in one step, you could concatenate them first, and then test for the string match.

Hi @Bill Sheboy 
I checked the link for text searching functions, as I wanted to do something similar, but I couldn't find anything for 'contains' other than contains all letter or all numbers, not matching keywords. 
How does the syntax to match keywords work? 

Hi, Matthew.  Please try using match() with a regular expression, and then check that the result is not empty to then add the relevant labels.

Hi @Bill Sheboy 

I should probably have created a new ticket but this is exactly what I was searching for. I am trying to do the same thing but I just started yesterday. 

would it be possible to further explain this:

 

  • trigger: issue created:
  • action: create variable with your list
  • advanced branch: splitting the created variable into a list
    • condition: check if the value is found (from the branch variable)
    • action: add the label
    • action: re-fetch the trigger issue

 

How do I create a list, I’ve read through the smart values list but I am unsure of how to create a list 

 

And once I do the check if the value is found, how do I input that as a label. I can’t see any way to pass the information from the list into the labels based on the results. If I could find out in general how this is done it would be great, because being able to pass the information from the branch to the action would be great 

 

your help would be highly appreciated.

Hi @Ryan Van Zyl -- Welcome to the Atlassian Community!

First thing: lists

To make a list, you supply the values with some delimiter, such as comma.  That will still be a text string.  Then when you need it as an actual list, you can use the split() function for use as needed.  For example...

  • Create a variable
    • Name: mySearchValues
    • Value: apple,orange,squirrel,diamond
  • Later when you want to iterate over the values as a list in the advanced branch, split it
    • smart value: {{mySearchValues.split(",")}}
    • variable name: {{myValue}}

Next thing: adding your found value as a label

This is the easy part, using Edit Issue, select Labels, the ... option to Add/Remove labels, and then just enter your smart value of {{myLabel}} from the branch.  The "trick" is to type in your smart value in the field and it will appear below the field; when it does, select it to use it.

Kind regards,
Bill

Thank you so much, I understand now how I am supposed to use smart values. I work for a big company (this is not my company email) and they want me to automate a lot so this really has saved me a lot of time.

Thank you so much again!

Like Bill Sheboy likes this

@Bill Sheboy @Ryan Van Zyl Can you elaborate on the first method explained (see below). I'm still not getting how to realise this.

"That would only require use of advanced compare conditions with "contains" or use of the text searching functions.

Regarding your ask about checking Summary and Description in one step, you could concatenate them first, and then test for the string match."

Hi @Melle van Keulen 

The idea would be to use functions, such as match(), to extract the text you want to search, and use the value to check in the second compare value.

Another approach, suggested earlier, is to build a list of value to check in a created variable, and then iterate over them with and advanced branch to check them one by one.

If you already have a rule which is not working as you expect, I suggest creating a new question, adding a link to this post, and including images of your complete rule and audit log details.  That will help more members of the community to see it and offer suggestions.  Otherwise only the people currently following this post will see your question.

Kind regards,
Bill

0 votes
Pramodh M Community Leader Jan 23, 2022

Hi @Daniel Helmstedt 

Welcome to the Community!!

If you have a predefined list of labels that's best, otherwise, it's not recommended.

Have the list of labels predefined, and going forward for once you need to create the label and add it in automation.

The Automation would go like this

Trigger - Issue Created

Condition - JQL Condition to check whether labels you manually added once is present in Summary/Description

Action - Add the label

Thanks,
Pramodh

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events