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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Automation - Set ticket Labels from a Variable



I have a set of Labels in my ticket (a,b,c).  In my automation I would like to save my labels in a temporary Variable (New Action > Advanced > Create Variable) and, at some point in the flow, restore these Labels according with conditions.

When I create the Variable I assign the value to a TMPLABEL as per below

{{issue.labels.join(",")}} // comma separated string



{{issue.labels.asJsonString.asJsonArray}} // Array


In the Edit Issue step I try with

  "fields": {
     "labels": [
       {{#TMPLABEL}}{{.}}, {{/}}


When the automation runs I get the error "Error while parsing additional fields. Not valid JSON."

Any idea?









1 answer

1 accepted

0 votes
Answer accepted
Hana Kučerová Community Leader Jan 13, 2021

Hi @Federico Zanetti ,

please try



"fields": {
"labels": {{#TMPLABEL}}{{.}}{{/}}

The problem with 

{{#TMPLABEL}}{{.}}, {{/}}

 is there will be comma after all labels (including the last one) and also the quotes will be missing - so this will result in something like:

label1, label2, label3,

But we need to create:

"label1", "label2", "label3"

I don't like my solution much, but this only combination worked for me.

Like Tessa Tuteleers likes this

Hi @Hana Kučerová,

it works perfectly!




Hi @Hana Kučerová,

on the same topic, what if I would like to restore a label according with a condition.

For instance, I have three labels "MY_PIZZA, YOUR_PIZZA, MY_CAKE" saved in a Variable and I would to restore just labels including "PIZZA" 

Following the example in the documentation, the most reasonable solution seems

{{#if(TMPLABEL.indexOf("_PIZZA").gt(0)) }}

However, when I run the automation, I get an error as per below

Error editing issues (data was not an array (labels))

Any thought?




Hana Kučerová Community Leader Jan 15, 2021

Hi @Federico Zanetti ,

I don't know about your use case much, but wouldn't it be possible to use automation conditions and action (Edit issue -> Labels -> Add/remove values) instead of working with variable?  It seems to me very complicated and after some time it will be hard to determine, what is your automation rule exactly doing.

Like Federico Zanetti likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

449 views 5 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you