The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Data for "labels" with multiple values

ray.mcmanemin
October 12, 2023

I am currently trying to leverage the "Custom data" approach for the "Web request body" for a given Automation trigger event and running into issues producing the "labels" array list of values with quotes ("") around each value:

Scenario #1:  "labels" has a single value of "value1":

"labels": [
     "{{issue.labels}}"
],

|--> produces for a single value: "value1"

"labels": [
     "value1"
],

Scenario #2:  "labels" has multiple values of "value1" and "value2":

"labels": [
     "{{issue.labels}}"
],

|--> produces both values: "value1" and "value2"

"labels": [
     "value1, value2"
],

|-> desired format  where each value has quotes ("") around the values:

"labels": [
     "value1",

     "value2"
],

Attempted this syntax / format:

{{#issue}}"{{labels}}{{^last}}",{{/}}{{/}}

|-> produces this result:

"labels": [
     "value1, value2",
],

Let me know if more details would help explain what I am attempting to achieve for multiple labels list.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

2 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
October 12, 2023

Hi @ray.mcmanemin 

Your expression has the quotation mark inside of the {{^last}} expression and it should be before that, like this:

{{#issue}}"{{labels}}"{{^last}},{{/}}{{/}}

And...you may not need this, as the asJsonStringArray can do all that for you, including the enclosing brackets:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-json-functions/#asJsonStringArray

Kind regards,
Bill

ray.mcmanemin
October 12, 2023

@Bill Sheboy  EXCELLENT guidance!....I was able to get the multiple labels properly formatted using that "asJsonStringArray" approach link you shared:

|-> FINAL Custom data format that worked:

      "labels": {{issue.labels.asJsonStringArray}},     

|-> RESULTING desired formatted values:

      "labels": [
            "value1",
            "value2"
      ],

FYI: the other suggestion above produced the same un-wanted format:

{{#issue}}"{{labels}}"{{^last}},{{/}}{{/}}

|-> Produced this formatted values: 

      "labels": [
            "value1, value2",
      ],

 

Thanks again for the quick response and getting me un-stuck.  Will mark this ticket as Resolved/Answered.

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
October 12, 2023

Arg...my bad as I answered too quickly: the labels are a list for this context and so that is where iteration is needed for your first version:

{{#issue.labels}}"{{.}}"{{^last}},{{/}}{{/}}
ray.mcmanemin
October 12, 2023

Nice...that works for me too! 

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events