Forums

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

Convert text in custom field to label with retaining existing labels

Jay Dubinsky
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!
August 12, 2022

Hi there,

I'm attempting to finalize the setup of automation that will convert the text within a custom text field into a label and add it to the existing labels on an issue. 

 

When I attempted to accomplish this feat, I've been unsuccessful but have been scratching my head with the syntax error I believe I'm facing. For those finding this in the future, maybe this will be helpful:

 

{
"fields": {
"labels": [
"{{issue.labels}}",
"{{issue.customfield_1111111.replace(" ","_").replaceAll("["$&+,:;=?@#|'<>.^*()%!-"]", "_")}}"
]
}
}

1 answer

1 vote
Oliver Siebenmarck _Polymetis Apps_
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, 2022

Hi @Jay Dubinsky ,

Welcome to the community! Hope you like it here and glad you're using labels – in my mind one of the coolest features of Jira.

Setting labels with Automation is not as straight-forward as one might want, but ultimately not too bad. I'll assume that you already got your trigger set up and are just looking for a way to add the label. Here's the what that would look like:

Bildschirmfoto 2022-08-12 um 13.25.15.png

The important thing to note here, is that you'll need to include the current labels with this line:

 "{{issue.labels}}",

Of course, instead of using a smart value to grab part of the summary, you'll want to get your custom field.

Hope that helps,
 Oliver

Jay Dubinsky
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!
August 12, 2022

Thank you so much Oliver, this was helpful! 

 

I was able to clean up some syntax issues I was running into so this was extremely helpful!

I forgot one small piece to this: the text field in use has spaces in between the name and I need to convert those to underscores to be accepted in a label. 

Below is the code I'm actively using without success:

 

Screen Shot 2022-08-12 at 11.35.12 AM.png

 

I sincerely appreciate all of the help! I'm just a bit puzzled on this one. 

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 12, 2022

Hi @Jay Dubinsky -- Welcome to the Atlassian Community!

Two things of note:

Please try the replace() function to substitute your spaces for underscores: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#replace-String-target--String-replacement-

And, when using the edit issue action, either select the field (from the dropdown) and enter your smart value expression, or use the advanced edit with JSON.  Do not try to use both for the same field, Labels.

Kind regards,
Bill

Suggest an answer

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

Atlassian Community Events