Forums

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

How to get the second last comment of a child issue

vincenzo.spatafora
Contributor
October 10, 2024

Dear ALL,

would you know which is the syntax to get the second-last comment of a child issue?

I have tried the followings out but they haven't worked:

 

{{issue.subtasks.comments.getFromEnd(1).body}}

{{issue.subtasks.comments getFromEnd(1).body}}

 

Thanks in advance, Vincenzo.

2 answers

1 accepted

0 votes
Answer accepted
Tuncay Senturk
Community Champion
October 10, 2024

Hi @vincenzo.spatafora 

As you know, there may be multiple child issues, and that's why .subtasks returns a list of issues. Therefore, you have to use get(0) if you are sure that there is at least one subtask.

{{issue.subtasks.get(0).comments.getFromEnd(1).body}}

If you have multiple subtasks and want to get the second-last comment from each, you can loop through them:

{{#issue.subtasks}} 
{{comments.getFromEnd(1).body}}
{{/}}

or add a lookup issues and try same approach there for each issue.

I hope that helps

vincenzo.spatafora
Contributor
October 16, 2024

Thanks a lot @Tuncay Senturk.

Yes, it helped me.

My Kind Regards, Vincenzo. 

Like Tuncay Senturk likes this
Tuncay Senturk
Community Champion
October 16, 2024

I'm glad it helped.

Like vincenzo.spatafora likes this
0 votes
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 15, 2024

Hi @vincenzo.spatafora 

This seems to be the same / related question as in your other thread: https://community.atlassian.com/t5/Jira-questions/Display-last-n-comments/qaq-p/1832584

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer