Forums

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

Jira Scriptrunner: Post function: Send a custom email: How to get most recent comment on issue

Klaus Foerschl
Contributor
October 22, 2019

Hello,
i'm following chapter "Comments in Emails" from  https://scriptrunner.adaptavist.com/latest/jira/builtin-scripts.html 

However, neither of the variables (lastComment, mostRecentComment or latestPriorComment) does give me the desired most recent comment on the issue.

e.g. my email template looks like this:
Additional info regarding this issue has been requested from you with this comment:<p>
mrc:$mostRecentComment
lpc:$latestPriorComment
lc:$lastComment
<p>
Please see details and use the <font color="green"><b>Provide Info</font></b> button at <a href="${baseurl}/browse/${issue.key}">${baseurl}/browse/${issue.key}</a>.<br>

but the send email looks like this:
Additional info regarding this issue has been requested from you with this comment:

mrc: lpc: lc:

Please see details and use the Provide Info button at ...

Anybody an idea what might be wrong?
There is definitely a comment on the issue, but added "log" time ago, at least not in the last transition.

 

1 answer

0 votes
Ben Poulson
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 22, 2019

Could you provide the script that sends the email? That would help to be able to diagnose why it isn't working.

 

Thank you!

Klaus Foerschl
Contributor
October 22, 2019


Hi Ben. Thanks for your reply.


As described, I've not written an own script, doing the email sending, but I'm using the ScriptRunner builtin script (post function) "Send a custom email"
The only thing I can customize there is the subject/body/receivers/... in a particular format, as described in the link in my initial posting.
And the problem is, that some "variables" which should be available within the template, are simply not replaced as described.

But, I meanwhile played around and found, that the position of this post function within the list of all post functions of the particular transition obviously makes a big difference, even I can't understand fully "why".
However, if I move this post function to the very end of all post functions it seems to work now. No idea what the difference should be if I anyway would like to get (transition independent) the most recent comment ($mostRecentComment) of the issue.

So, finally I have a working setup now. But still I have no explanation for the failures.

Thanks
Klaus

Suggest an answer

Log in or Sign up to answer