How to reference a property in the last object in an array of objects with ConfiForms

Davin Studer
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.
December 27, 2019

I've got a ConfiForms form with a Jira issue field. The field is of the type Jira issue. By default comments for the issue are not available using the dot notation. I figured out that I can add comments into the object by adding in "comment" into the "Limit to these fields when fetching issues" box.

image.png

As an example, I can now access the comments like such ...

issueKey.fields.comment.comments[0].body

My question is this. How do I get the most recent comment? Using comments[0] will get me the first comment, but really I want the last comment. Anybody know how to do that? Is there a virtual function that I can use for this?

1 answer

1 accepted

1 vote
Answer accepted
Davin Studer
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.
December 27, 2019

Ok, I think I found out how to do it. After MUCH trial and error I had to do this ...

issueKey.fields.comment.comments.asJSON.get().body
Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 27, 2019

Sorry for causing you troubles with the lack of documentation on this scenario.

I am surprised about the solution :-)

 

I think we need to add something like index=-1 and make something like this to work

issueKey.fields.comment.comments[-1].body

or support empty index 

issueKey.fields.comment.comments[].body

What do you think, @Davin Studer ?

Like Davin Studer likes this
Davin Studer
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.
December 27, 2019

@Alex Medved _ConfiForms_ Yeah, I think one of those would work. Maybe the first would be the best such that you could even do -2, -3, etc to get the second to last, third to last, and so forth.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events