I want to display the last comment made on an issue in a custom email template.
I have the following:
<td><% out << componentManager.commentManager.getComments(issue)?.last()?.body %>
which happily shows the last comment, but fails for issue where there are no comments.
I'm sure there is a way to add an 'If' statement to this to handle the error but can't seem to get it to work... any help greatfully appreciated.
Matt - your way is fine, but the last comment is placed in the binding, so you can just do as in the example in the docs: https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Sendacustomemail
<% if (lastComment) out << "Last comment: " << lastComment %>
This gives the following error..
groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: GStringTemplateScript95.groovy: 36: unexpected token: < @ line 36, column 9. <% out << componentManager.commentManager.getComments(issue)?.last()?.body ; ^ 1 error
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!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot