Adding Email Audit Log to email templates

SINCE VERSION 5.3.2.2

In case you want to render issue email audit log in your email, you must edit your email templates. The key attribute is $!issue.auditLog that returns a list of email audit log entries or an empty list.

When selecting Email Log in the Field Picker dropdown list, you will get instructions on how to easily include issue email audit log information in the template.

In case you want a customized display (e.g. apply different layout or styles), then you can start to add these template fragments directly into your templates and customize them according to your needs.

Example for rendering an issue email audit log in HTML emails

#macro (addTableHead $headerLabel)
    #if ($!isJIRA61OrLater)
        <th><strong style="font-weight:normal;color:${textSubtleColour};">$headerLabel</strong></th>
    #else
        <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};">$headerLabel</strong></td>
    #end
#end
#macro (beginTd)
    #if ($!isJIRA61OrLater)
    <td>
    #else
    <td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;">
    #end
#end
#macro (endTd)
    </td>
#end
#set($auditLog = $!issue.auditLog)
#if ($!auditLog && $!auditLog.isEmpty() == false)
<h3>Emails</h3>
<table>
<tr valign="top">
    #beginTd()
    #foreach($audit in $!auditLog)
          <div class="issue-data-block">
              <div class="actionContainer">
                  <div class="action-details">
                      $!audit.senderName $!audit.actionLabel  - <span class="date">$!audit.timestamp</span>
                  </div>
                  <div class="action-body222">
                      <table>
                          #if($!audit.from)
                          #set($fromHtml = $!audit.from)
                          <tr valign="top">
                              #addTableHead($i18n.getText("email.audit.from"))
                              #beginTd()
                              $!fromHtml
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.to)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.to"))
                              #beginTd()
                                  <span class="email-to-full">$!{audit.to.fullLabel}</span>
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.cc)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.cc"))
                              #beginTd()
                                  <span class="email-to-full">$!{audit.cc.fullLabel}</span>
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.bcc)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.bcc"))
                              #beginTd()
                                  <span class="email-to-full">$!{audit.bcc.fullLabel}</span>
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.emailSubject)
                          #set($subjectHtml=$!audit.emailSubject)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.subject"))
                              #beginTd()
                              $!subjectHtml
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.emailBody)
                          #set($bodyHtml = $!audit.emailBody)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.body"))
                              #beginTd()
                              $!bodyHtml
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.attachments)
                          #set($attachmentsHtml = $!audit.attachments)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.attachments"))
                              #beginTd()
                              $attachmentsHtml
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.options)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.mail.options"))
                              #beginTd()
                                  <ul>
                                      #if($!audit.addComments)
                                      <li>$i18n.getText("issuemail.form.options.add.comments")</li>
                                      #end
                                      #if($!audit.replyToMe)
                                      <li>$i18n.getText("issuemail.form.options.from.me")</li>
                                      #end
                                      #if($!audit.addToWatcher)
                                      <li>$i18n.getText("issuemail.form.options.add.to.watchers")</li>
                                      #end
                                  </ul>
                              #endTd()
                          </tr>
                          #end
                      </table>
                  </div>
              </div>
          </div>
    #end
    #endTd()
</tr>
</table>
#end

Example for rendering issue email audit log information in TEXT emails

#set($auditLog = $!issue.auditLog)
#if ($!auditLog && $!auditLog.isEmpty() == false)
Emails:
#foreach($audit in $!auditLog)
Action:$!audit.senderName $!audit.actionLabel - $!audit.timestamp
------------------
#if($!audit.from)
$stringUtils.leftPad($i18n.getText("email.audit.from"), $padSize) $!audit.auditLogEntry.from
#end
#if($!audit.to)
$stringUtils.leftPad($i18n.getText("issuemail.form.to"), $padSize) $!{audit.auditLogEntry.to}
#end
#if($!audit.cc)
$stringUtils.leftPad($i18n.getText("issuemail.form.cc"), $padSize) $!{audit.auditLogEntry.cc}
#end
#if($!audit.bcc)
$stringUtils.leftPad($i18n.getText("issuemail.form.bcc"), $padSize) $!{audit.auditLogEntry.bcc}
#end
#if($!audit.emailSubject)
$stringUtils.leftPad($i18n.getText("issuemail.form.subject"), $padSize) $!audit.auditLogEntry.emailSubject
#end
#if($!audit.emailBody)
$stringUtils.leftPad($i18n.getText("issuemail.form.body"), $padSize) $!audit.auditLogEntry.emailBody
#end
#if($!audit.attachments)
$stringUtils.leftPad($i18n.getText("issuemail.form.attachments"), $padSize) $!audit.auditLogEntry.attachments
#end
#if($!audit.options)
$stringUtils.leftPad($i18n.getText("issuemail.form.mail.options"), $padSize): #if($!audit.addComments)$i18n.getText("issuemail.form.options.add.comments"), #end #if($!audit.replyToMe)$i18n.getText("issuemail.form.options.from.me"), #end #if($!audit.addToWatcher)$i18n.getText("issuemail.form.options.add.to.watchers")#end
#end
#end
#end

Last updated