Hi All,
My usecase is this ticket - https://community.atlassian.com/t5/Jira-Software-questions/Smart-values-for-copying-multiple-labels/qaq-p/1882892
I have a variable {{varLabels}} which holds an array ["ABC", "DEF"] of labels I got from parent which I need to "add" to its stories.
When I go to advanced editing and I want to set the labels, the syntax suggested by @Bill Sheboy works as expected, but when I try to add the labels instead, instead of individual labels, whole array gets added as 1 label.
{ "fields": { "labels": {{varLabels}} } } <-- works
{ "update": { "labels": [ {"add": {{varLabels}}} ] } } <-- throws an error that operation value must be a string
{ "update": { "labels": [ {"add": "{{varLabels}}"} ] } } <-- does not work, updates complete array as single label.
I am thinking its cause the "add" method expects a single string based on documentation.. so I wanted to understand if there are any work arounds to this problem. Thanks!
Without seeing the specifics of your rule or audit log details...
Please review the syntax differences for setting versus adding labels with JSON, write your created variable to the audit log, and then adjust accordingly: https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Adding-labels
Kind regards,
Bill
Thanks Bill, using your response from my other thread, I was able to format my JSON to "adding" & "removing" labels. You are AWESOME!
-----------------------------------
If my labels list were in a variable (mylabels),
mylabels = 124, 345, ABC
I used your suggestion to format the JSON as below
[ {{#mylabels.split(", ")}}{ "remove" : "{{.}}" }{{^last}}, {{/}}{{/}} ]
which then gave output as:
[ { "remove" : "124" }, { "remove" : "345" }, { "remove" : "ABC" } ]
I then stored the output in a new variable (newVar).
Then i used advanced edit to remove the labels from the issue:
{
"update": {
"labels": {{newVar}}
}
}
NOTE: I tried a lot to use @Bill Sheboy solution from here to format JSON the way he suggested but I keep getting JSON formating error. I am in Data center edition, I will keep trying that approach as well and edit this post if that route is also possible.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.