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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 Edited

Hi 

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

Var.png

or

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

VarJson.png

In the Edit Issue step I try with

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

Loop_01.png

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

Any idea?

Thanks

--

Federico 

 

 

 

 

 

1 answer

1 accepted

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

Hi @Federico Zanetti ,

please try

{{issue.labels.asJsonStringArray}}

and

{
"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!

Thanks

--

Federico

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?

Thanks

--

Federico

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
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Why you should move agile planning to Lucidspark’s digital whiteboard

During my 17 years as a coach, mentor, and trainer of Agile teams, I’ve participated in hundreds of Agile planning meetings. The end result was a wall of backlog items annotated by an explosion of co...

91 views 0 5
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