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,363,022
Community Members
 
Community Events
168
Community Groups

Convert text in custom field to label with retaining existing labels

Edited

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

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

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. 

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

Atlassian Community Events