Forums

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

Use smart values to access an array

Gil
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.
September 23, 2020

Hi all.

I'm trying to access the Affect Versions field in JSD support ticket and post it in a Slack notification.

 

Using the smart values and reading the document here: https://support.atlassian.com/jira-software-cloud/docs/use-smart-values-to-access-listed-values/

My automation rule log is not able to pick up the value in the Affect Versions field.

Using the REST API browser I can see the following:

"versions": [{"self": "https://my-domain.atlassian.net/rest/api/3/version/14214","id": "14214","name": "1.9.0","archived": false,"released": true,"releaseDate": "2020-06-03"}],

 

I thought that the smart value will be {{versions.name}}, but since this is an array, I was trying to use 

{{issue.versions.name.join(", ")}}

or

{{#issue.versions}}{{name}} {{/}}

but nothing seems to pick up the version name from that array.

 

Appreciate your help.

 

 

2 answers

1 accepted

1 vote
Answer accepted
Veera
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 6, 2020

Just for other community members benefit, posting the answer I have provided to Gil in Support ticket.

This is how we can get version name and release date values from Affects Versions system field using smart values.

To get the version name, use:

{{issue.versions.first.name.asJsonString}}

And for version release date:

{{issue.versions.first.releaseDate}}

Screenshot:

Screen Shot 2020-09-30 at 3.08.38 pm.png

If you want to get rid of double quotes from version name, use:

{{issue.versions.first.name.jsonEncode}}

 

0 votes
Mark Chaimungkalanont
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 24, 2020

Hey there Gil,

Most of our smart values matches the data returned through REST for the issue, i.e. through /rest/api/2/issue/ISSUEKEY-1?expand=names,renderedFields,changelog

More specific examples can be found at:

https://support.atlassian.com/jira-software-cloud/docs/smart-values-general/

In your specific case, the right field name is actually version not versions so, for affects versions, you should be able to do:

{{issue.version.name}}

And it will concatenate the affect versions.

Cheers,

Mark C

Gil
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.
September 24, 2020

Hi @Mark Chaimungkalanont 

Thanks for the answer.

According to your documentation, the examples listed there use the value Versions and not Version.

See:

image.png

(source: the link you provided)

 

So which one is it? Do you need to amend your documentation?

 

---

Whether it's Version or Versions, given the Affect Versions is a list, would this be a correct way to do this?

{{#issue.versions}}{{name}} {{releaseDate}}, {{/}}

Or is this the correct way?

{{#issue.versions.name}} {{releaseDate}}, {{/}}

 

Update:

I tried all of these combinations and none of them work:

Version: {{issue.version.name}} | {{issue.versions.name}} | {{issue.version}} | {{versions.name}}

The LOG returned empty results.

 

Mark Chaimungkalanont
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 24, 2020

Ah sorry, my bad. Looks like we've got wrong and right documentation on that page. 

Smart_values_-_general___Jira_Software_Cloud___Atlassian_Support.png

We'll get that fixed up

--- 

{{#issue.versions}}{{name}} {{releaseDate}}, {{/}}

 

This is the correct style (the # sets the object as the main object inside that context)

We do some smart defaults so if you want a simple value we auto-concatenate the strings, so {{issue.versions.name}} will output Version 1, Version 2

Gil
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.
September 24, 2020

@Mark Chaimungkalanont  I'm getting empty results.

The LOG lists nothing.

image.png

Gil
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.
September 27, 2020

Hi @Mark Chaimungkalanont 

I tried this whole weekend to get the log to show the Affects Versions.

Can I please get your assistance on this one?

See my above screenshot. It is empty.

Mark Chaimungkalanont
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 28, 2020

Hey there Gil,

Sorry to hear... That smart value works fine for me so it's probably something specific here. Does outputting {{issue.versions}} show anything? Is your issue using the system Affects Versions or is it a custom field of type version?

Can you raise a support request at https://getsupport.atlassian.com/ and we can check it out on your instance.

Cheers,

Mark C

Gil
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.
September 28, 2020

Thank @Mark Chaimungkalanont 

Raised PCS-17865

Mark Chaimungkalanont
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 28, 2020

Cool I'll follow up there. Looks like a weird one

Suggest an answer

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

Atlassian Community Events