Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
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

Custom Data for "labels" with multiple values

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.
Oct 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

@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.
Oct 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}},{{/}}{{/}}

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