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

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 Leaders.
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 Leaders.
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! 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events