Using "lastComment" in listener "Send Custom Mail"

Hi everyone

I recently updated to ScriptRunner 4.3.9 and since then you can use some advanced scripting in the "condition and configuration" section of the listener "Send Custom Mail".

However, when I try to use "lastComment" like i usually did in my mail template, it states the variable is undeclared.

image2016-10-11 10:24:37.png

I also tried issue.lastComment, $issue.lastComment etc. No luck though.

Can somene help here?

Best Regards


1 answer

Hi Marius,

I have attached a little script below which I use to get the last comment in a scripted field. You should be able to get the last comment in the same sort of way inside of your listener.

import com.atlassian.jira.component.ComponentAccessor

def comments = ComponentAccessor.getCommentManager()?.getComments(issue)

if (comments) {
    return comments.last()?.body


I hope this helps.



Hey Kristian,

Thanks for that script

However, it seems like this would just return the newest comment ever made on that issue. I would like to only get the comment which was made during that transition if any has been made at all.

I use this listener for when an issue gets closed and I would like to extract the described resolution out of transition that triggered the listener.

Best Regards


Hi Marius,

I will create a bug for this (SRJIRA-2066), you are right the comment variables are not bound and ready-to-use at the additional configuration field. 

You can use them though in the email template as before , for example

Last Comment: ${lastComment}
Most recent comment: ${mostRecentComment}

regards, Thanos

Hi Thanos,

Okay, cool.

Thanks to both of you for your help smile

Best Regards,


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


251 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you