Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira Automation - Smart Value to Extract Label from Issue

jeanine August 9, 2022

Hello,

I am working with jira automation and smart values and am running into a blocker when trying to extract just one label (out of 2-3) from an issue. I would like to extract an application name from a label such as "app_AppXYZ" and was successful in doing so using the following: {{issue.labels.substringAfter("app_")}}

However, the issues will have 2-3 other labels and the end result comes out as "AppXYZ,,," (the 3 commas being the other labels).

I tried to use {{issue.labels.substringBetween("app_","the_other_label")}} as well as {{issue.labels.substringBetween("app_",",")}} but neither were successful. 

Any suggestions or help would be so appreciated! Thank you!
 

1 answer

1 accepted

0 votes
Answer accepted
Bill Sheboy
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 9, 2022

Hi @jeanine -- Welcome to the Atlassian Community!

As you note, the labels smart value is a list, so you can merge everything together, and then parse, or filter first.  Two of the ways to solve this are:

Kind regards,
Bill

jeanine August 10, 2022

Hi @Bill Sheboy 

Thank you for the quick answer!

For option one, I attempted to combine two smart values into one such as {{issue.labels.substringAfter("app_").substringBefore(",")}} but it seems it did not honor the second statement and the commas were still returned. Would you be able to provide more context as to how to use two smart values in one statement? 

Or perhaps you can help me understand where to store the first value (app name,,,) so that I may use the second smart value on it and extract only the name.

I appreciate your help!

 

Best,

Jeanine

Bill Sheboy
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 10, 2022

Sorry I wasn't more clear...Your first parsing of Labels is still going to produce a list result, and so that needs to become text (a string) before using substringBefore() or maybe remove()

Perhaps like this:

  • Create a variable, storing the result of your first parsing on "app_".  Let's call it varApps
  • That variable is now text, and you can remove the stray commas with {{varApps.remove(",")}}

Using remove() is better for your use case as it can handle the application name being in the middle of the results.

Like avinash.kagita likes this
jeanine August 10, 2022

Thank you @Bill Sheboy 

Like Bill Sheboy likes this
avinash.kagita
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 25, 2022

Thank you @Bill Sheboy  this fixed my issue

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events