Using "lastComment" in listener "Send Custom Mail"

Deleted user October 10, 2016

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

Marius

1 answer

2 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 10, 2016

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.

Thanks

Kristian

Deleted user October 10, 2016

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

Marius

Thanos Batagiannis _Adaptavist_
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 11, 2016

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

Deleted user October 11, 2016

Hi Thanos,

Okay, cool.

Thanks to both of you for your help smile

Best Regards,

Marius

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events