Forums

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

New comment in custom email body (Script Runner, built-in script 'Send custom email')

Kate
Contributor
March 21, 2013

Hi!

I need advice.

I use built-in script "Send custom email": https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-SendCustomEmail

Event: Issue commented

Condition: issue.status?.name == 'New'

Subject template: Issue $issue was commented

How can I paste new comment in 'Email Template'?

5 answers

1 accepted

1 vote
Answer accepted
JamieA
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.
March 25, 2013

Thanks for finding that Daniel... however I think that will fall over when there are no comments.

I have updated the sample template in https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Sendacustomemail (Point 3).

Make sure you use the if, or if you don't, at least test it with an issue with and without comments in builtin scripts -> Send a custom mail (which is used for testing templates).

Kate
Contributor
March 26, 2013

I like this template, thanks :)

francis
Atlassian Partner
May 21, 2014

Jamie,

How do you get the comment of the last transition - if any.
lastComment is set, even if the transition didn't have any comment,
so containing a comment which is not relevant to the transition.

Francis

JamieA
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.
May 22, 2014

Yeah... that's no good is it. Can you create a bug, I will try to fix. I don't think the email template has access to transientVars or event, to get the comment added on that transition.

francis
Atlassian Partner
May 22, 2014

Access to transientvars would fix this issue.
https://jamieechlin.atlassian.net/browse/GRV-449

Francis

JamieA
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.
May 22, 2014

And the event if it's a listener, but yes indeed. Thanks for the issue.

Arianna Fabbri
Contributor
April 27, 2015

Hi @Jamie Echlin [Adaptavist], how can I get, in a custom email template, the transition's comment author? Thank you in advance Arianna

JamieA
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.
April 29, 2015

It will be: comment.author

Arianna Fabbri
Contributor
April 29, 2015

Hi @Jamie Echlin [Adaptavist] , if I use <% out << comment.author %> I get, on preview, No such property: comment for class: groovy.lang.Binding Any suggestion? Thank you again

JamieA
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.
April 30, 2015
0 votes
Kate
Contributor
March 26, 2013

yeeeeeah :)

Thanks!!

0 votes
DanielP
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.
March 25, 2013

Sorry, it wasn't as simple as I thought.

try

&lt;% out &lt;&lt; componentManager.commentManager.getComments(issue)?.last()?.body %&gt;

Found the answer in this comment.

0 votes
Kate
Contributor
March 25, 2013

no result :(

this listener works if i paste some constant text, but with this line - no

0 votes
DanielP
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.
March 25, 2013

Hi,

simply adding the line:

$comment.getBody()

should "paste" the new comment into the email.

You should check https://confluence.atlassian.com/display/JIRA043/Velocity+Context+for+Email+Templates for more info.

Suggest an answer

Log in or Sign up to answer