Add Issue Comments to Emails

JETI's default email template (called Default in the template editor) is prepared to render comments into the email body when the "Add comments to outgoing emails" options is enabled. However, if you develop your own custom email template from scratch or not based on Default, you'll have to add velocity template code to render the comments.

In order to append issue comments to the outgoing emails, two requirements must be met:

  1. You enable the option "Add comments to outgoing emails" in the corresponding component (Email button, Bulk Email, Post Function, Event Notification)
  2. You add a template fragement to your email template  that will render the comments.

The template fragements are different for HTML and TEXT emails. Copy and paste the below code to your templates or use the Field Picker dropdown and select "Comment".

Non-restricted comments only

Only public (non restrcited, i.e. Visible by anyone) comments are added to the emails. This is done to prevent revealing secured comments unintentionally. 

Comments in HTML Emails

Add Comments to HTML Templates
#if ($!emailDef.emailOptions.addComments)
<tr valign="top">
    <td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 10px 10px 0;white-space:nowrap;">
        <strong style="font-weight:normal;color:${textSubtleColour};">#text("common.words.comments"):</strong>
    </td>
    <td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;">
        #foreach ($comment in $!publicComments)
        <p style="border-bottom: 1px solid #DDD;>
            <p style="font-weight: bold"><a href="$!baseurl/secure/ViewProfile.jspa?name=$!{comment.author}"><b>$!{comment.authorFullName}</b></a> - <b>$!{dateformatter.format($comment.created)}</b></p>
            <p>$!{rendererManager.getRenderedContent($!commentRendererType, $!comment.body, $issue.issueRenderContext)}</p>
        </p>
        #end
    </td>
</tr>
#end

Comments in Text Emails

Add Comments to TEXT Templates
-------------------------------------------------------------------------------
#if ($!emailDef.emailOptions.addComments)
$i18n.getText("common.words.comments"):
#foreach ($comment in $!publicComments)
$!{comment.authorFullName} - $!{dateformatter.format($comment.created)}
------------------
$comment.body
#end
#end



Reverse Comment List

Normally comments are rendered by date ascending. To render them latest on top, you must reverse the list:

#set($publicComments = $!jetiFieldRenderer.reverse($!publicComments))

Last Comment

In operations when the users enter a comment (like issue update, or workflow transitions), the comment they enter can be referred to as $!comment or $!htmlComment depending on the content type of the template.

In other cases, afte reversing the comment list, you can access the last one easily:

#if($!publicComments && !$!publicComments.empty)
  #set($lastComment = $!publicComments.get(0))
  ...
#end

 

Without reversing the list first, access the last comment as:

#if($!publicComments && !$!publicComments.empty)
  #set($lastComment = $!publicComments.get($!publicComments.size()-1))
  ...
#end

Acces All Comments (even restricted ones)

To access all comments of an issue, use the $commentManager object.

#foreach ($comment in $!commentManager.getComments($!issue))
...
#end