Forums

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

how do I access elements from Smart Values returned via asJSONStringArray?

Bob Kleinberg August 26, 2023

In https://confluence.atlassian.com/automation/jira-smart-values-json-functions-993924865.html, there are functions for returning items from issues using the asJsonStringArray (or asJsonArray.

However, I am trying to use this information inside an email that I am sending out as part of an Automation function.  

For example,

{{issue.customfield_10106.id.asJsonStringArray}}

appears in the email as 

["475","476"]

What I'd like is to have just the 476 retrieved from the Smart value.  I've tried:

{{issue.customfield_10106.id.asJsonStringArray[0]}}
{{issue.customfield_10106.id.asJsonStringArray[1]}}

which I would have hoped would retrieve the "475" (0-based array) and the "476".

But, I get nothing but blank lines.

I've tried other ideas, but to no avail.  For example, issue.customfield_10106 is a JSON array of approval objects.  "id" is the approval number.  (475 or 476) for the same issue (it was approved, then reinjected to the point of waiting for a second approval after "additional work" was done (this was a test).  So, I've also tried to access the specific approval item, e.g., {{issue.customfield_10106[0].id}} which failed as well.

The point ultimate need is for the last of the list to be accessed (in this example, 476).

If you look at the REST API result for Get of the test issue, you get this (I've collapsed unnecessary sub fields):

Screenshot 2023-08-26 150215.png

Any suggestions from anyone on how I can get access to the specific ID?

 

1 answer

1 accepted

3 votes
Answer accepted
Bob Kleinberg August 26, 2023

Well, solved my own problem by digging into https://confluence.atlassian.com/automation/jira-smart-values-lists-993924868.html

using 

{{issue.customfield_10106.last.id}}

gave the answer of 476.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.4.8
TAGS
AUG Leaders

Atlassian Community Events