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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

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,456,659
Community Members
 
Community Events
176
Community Groups

Populating Labels Based on Assignee (Issue with parsing JSON)

Hello,

I'm trying to build an automation to update the label with the assignee display name-HI when the assignee is changed. Since labels do not accept spaces, I need to use the advanced fields (https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json/ and https://confluence.atlassian.com/jirakb/automation-for-jira-fails-to-copy-components-list-to-label-with-error-message-the-label-contains-spaces-which-is-invalid-1072473388.html) .

 

So, if I assignee an issue to a user named First Last, I'd like the label to be FirstLast-Hi

 

I have attempted dozens of configurations , but always get an error. I am hoping someone can assist in getting this to work:

 

 

 

{

    "update": {

        "labels": [{

                "add": "{{assignee.displayName.remove(" ").concat("-RH")}}"

        }]

    }

}

 

 

Here's the error:

Error editing issues: (Field labels cannot appear in both 'fields' and 'update')

 

Thank you in advance!
Allison

1 answer

1 vote

Hi @Allison 

I noted that you have nested double-quoting in your update, due to formula usage.  Have you tried to work around that by switching to single-quotes inside?

 "add": "{{assignee.displayName.remove(' ').concat('-RH')}}"

Or, you could save the right-side value to a created variable and then use that one.

Best regards,
Bill

Thank you for your reply, Bill! 

I attempted to replace the double quotes with single quotes and still had the same result.  (Field labels cannot appear in both 'fields' and 'update')

 

Taking the next step of your advice, I tried to remove the second value/calculation and had the same result. 

 

It seems the syntax is correct, so I'm stumped! Thanks so much for the help!

Fascinating...It appears that concat() will not work with single quotation marks.

So one workaround is to put this in a created variable and then set the labels to it:

{{issue.assignee.displayName.remove(" ").concat("-RH")}}

To set the labels to the smart value from the created variable (e.g. let's say we named it varAssigneeLabel

  • select the edit issue action
  • select the labels field
  • type in the smart value {{varAssigneeLabel}}
  • And then when it displays below the field, select that value
  • Confirm that is what is now shown in the field value

Thanks Bill! Is this feature available in Jira Server? From what I see you posted on another article, it seems I may be out of luck on the workaround, too. https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Create-variable-New-component/ba-p/1448118

I just figured it out!

The syntax of the first example was correct. The issue was that I had the labels set to be cleared (look under the cog icon)

Screenshot from 2021-07-30 15-50-11.png

 

Once I removed the "this field will be cleared action" everything worked. I think the two settings were conflicting each other throwing it into a loop.
Screenshot from 2021-07-30 15-50-45.png

 

 

Thanks again for your help!

Like # people like this

Sorry about that!  I noted the tagging which indicated you were using Cloud.

I just tried this and it worked for cloud, so you'll need to test for server: just do it directly without a variable or JSON edit...

Edit issue for the labels field, and paste that smart value expression in directly.  When it shows beneath the field, and save.  Then try the rule:

{{issue.assignee.displayName.remove(" ").concat("-RH")}}

Ah, two edits of labels.  If you noted above, you may also be able to do this without the advanced edit.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events