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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


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
Community Members
Community Events
Community Groups

concatenate an item in to issue.labels.asJsonStringArray ?

I'm trying to copy the array of labels from the original issue (when creating a new issue) _and_ add a new label at the same time... it seems to allow copy of old but not add at same time. I can get it to "add" two smart variables and have a variable for each of these, but the one is an array... and it gives formatting errors because it's not proper json when I add them next to each other. Is there a way to concatenate an item in to issue.labels.asJsonStringArray so it outputs one proper list?

3 answers

1 accepted

1 vote
Answer accepted
Mark Segall Community Leader Feb 18, 2022

Hi @Dane Kantner - If you're looking to add new labels, you could do so in a second action.  For the first action, create the issue and copy the labels.  Then create a branch on the newly created issue and edit the issue with the new fields you wish to add.  Something like this:


Thank you -- I didn't realize I could do a branch off of created issues specifically and was assuming I had to come up w/ the JQL to find it (and there is no valid JQL to find what I had just created, the label I'm trying to add is actually a unique identifier that I could search on but it doesn't exist yet)

0 votes
Stefan Salzl Community Leader Feb 19, 2022

I was facing same behaviour yesterday and was reading through documentation:


The documentation says:

A system field that is an array of text values.

"labels" : ["examplelabelnumber1", "examplelabelnumber2"] 


and further:
For fields that take arrays of text:

"fields": {
"labels": {{issue.parent.labels.asJsonStringArray}}


Description of the behaviour:
I want to add more than 1 labels from one issue to another one (eg. from parent to child) whereas the let´s say the child already got 2 labels and the parent has 2 different labels.

I tried to update a linked issue´s label field as follows:

"update": {
"labels": [
"add": {{destinationIssue.labels.asJsonStringArray}}


but audit log output says looks like:



@Darryl Lee , @Mark Segall :
Did I get anything wrong regarding the field or stringArray? Or could that be a bug?



I am trying to take triggerIssue.labels.asJsonStringArray and add a value to it so that the original triggerIssue.labels are kept BUT ALSO adding another string value to that list.

Darryl Lee Community Leader Feb 19, 2022

@Dane Kantner Adding a label to the newly created issue should not affect the triggerIssue. 

As to @Stefan Salzlssue, it looks like the "add" function can only take a string, not an array. I think there's a way to expand out the array but I need to test if it works with "add"... standby. 

Like Stefan Salzl likes this

I'm not trying to modify the trigger issue, I'm just trying to copy it labels array and add one more item to it to it in the newly created issue. The labels.asJsonStringArray does return the labels from the original issue properly as expected, and I can use that to add to the created issue, but the documentation says you can't set or add the fields twice, so it really needs to be added in to that string array in order to properly solve this issue, hence the question on how to concatenate to that array.  (The ability to add it after the fact as a branch edit is an OK work-around but it's not perfect b/c it does delay processing an extra second or two; a second edit is much more expensive than a local variable edit to the labels array and adding it in to the field from the origination of the new issue create; I wonder since the add to array functionality doesn't exist if I could use regex to transform the returned JsonStringArray to alter it to inject a new string?)

I really don't think that adding a label afterwards will slow it down that much, and it's a much more readable rule.

But since I'm a glutton for punishment...

Figured out how to make this work via Advanced editing using JSON using a few replaces, along with a split, and then another conversion back to an array:

     "fields": {
          "labels": {{issue.labels.asJsonStringArray.replace("[","").replace("]",",\"new-label\"").split(",").asJsonArray}}

Note that you can't set this using the normal field setting, because in that interface, the Labels field can only take strings that are separated out in the UI. I could not figure out a way to pass it a list/array directly, and giving it a comma-delimited string just created one really long label.

Like Dane Kantner likes this

Thanks I will give that replace gig a whirl -- it's ugly to h ave to read, but I've seen worse. :P I will potentially need to test if the jsonarray is empty to begin with too for robustness sakes.


The issue of why a second edit is "expensive" compared to doing it all in one create or edit is I may be creating 20 issues sequentially rather fast, and each of those creates fires a trigger rule where it's then trying to group/classify the finding in to a "resource" issue type and creates a "resource" issue OR groups it in to that existing resource issue that may have just been created. In the subsequent triggers, a 1s delay means I have to essentially delay the actual finding creations themselves by the equivalent amount of time to guarantee it has been processed. I had to add a 1s delay in initial creations already after making the change as a branch edit. If I can take it from 1s extra processing to 10ms, that's a lot more throughput at EOD.

Like Stefan Salzl likes this
Darryl Lee Community Leader Feb 21, 2022

Ah, ok makes sense that you'd want to minimize extra branches with multiple issue creation.

Speaking of checking for an empty array, I didn't think about that until I tried to solve @Stefan Salzl's problem using a similar approach.

Please see my updated code below, that in fact checks to make sure the triggering issue's Labels array isn't empty.

Like # people like this
0 votes

The other approach that is fiddlier, but potentially more powerful, is to use Advanced Edit as part of Create New Issue:

Luckily there's an example in the documentation!

I think this would work:

        "labels": [{
                "add": "extra-label"


Oops, my idea above isn't quite right, because I ended up with this error when trying to both Copy Labels from the Current Issue *and* add the extra one in the More options -> Additional fields JSON section:

Error creating issue
    Field 'labels' cannot appear in both 'fields' and 'update'

So then, as mentioned in the other thread, here's what ultimately did work, in case you wanted to also mark this answer as correct, since I think it's a little closer to what you were looking for.

Again, this would go in the More options -> Additional fields section when you Create a new issue:

     "fields": {
          "labels": {{issue.labels.asJsonStringArray.replace("[","").replace("]",",\"new-label\"").split(",").asJsonArray}}

Like Stefan Salzl likes this
Darryl Lee Community Leader Feb 21, 2022

Ooof, I realize this "fix" has the same problem as what I thought was going to fix @Stefan Salzl's issue:

I didn't account for the possibility that the original issue may not have *any* labels. Augh. So in that case I end up with an extra leading comma, which is not valid JSON:

"labels": [,"new-label"]

Ok, the fix is fixed. Ugh, sure would be nice if Automation had an ELSE function.

     "fields": {
         "labels": [

This is *much* cleaner than all of that JsonArray hackery though. Whew.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events