I am working on Automation to send the last n comments through email. For example, an issue contains 4 comments. Comments 1-4. I know that in order to get the latest comment I use {{issue.comments.last.body}}. Is it possible to show comments 2-4?
Hi @Vanessa Marie Delfin -- Welcome to the Atlassian Community!
Have you tried this function: getFromEnd()
https://support.atlassian.com/jira-software-cloud/docs/smart-values-lists/#Smartvalueslists-list.getFromEnd-index-
You could first check if {{issue.comment.size}} is < 5 and then show the whole list, or use the function and count backwards for your values: 3, 2, 1, 0
Kind regards,Bill
Hello @Bill Sheboy Thank you for the welcome!
I'm sorry I explained my situation wrong. If I have an issue that contains 10 comments and I want to print out the last 3 comments including the author's name
I thought about using the getFromEnd function like you suggested but it will not work in my situation since the index is static. For an issue with 10 comments, I will put
getFromEnd(10)
getFromEnd(9)
getFromEnd(8)
but if the issue gets a new comment, now a total 11 comments, it will always get the comments 10 9 8.
I need something more dynamic and after looking at the link you gave me it might not be possible. Would you happen to know of a different approach?
Hi @Vanessa Marie Delfin
The index used in getFromEnd() is relative from the end of the list. I just tried this again with my test rule, and when I use:
Here is my test rule, which successfully wrote the correct comments to the audit log.
Hi @Bill Sheboy, happy to find you in here.
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.
It looks like you're new here. Sign in or register to get started.