Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 2 Current »

Adding comments into adhoc can increase the size of the content a lot.

Example script

This script works with Software and JSM Project types, it excludes (Software) comments that have a Visibility Level (Role / Group) set that would typically not be expected to be sent to external parties, same goes for (JSM) internal comments.

The $wikiRenderer.render($comment.getBody(),null) is required to convert the markup of the comment body to HTML.

#set ($projectType = $issue.getProjectObject().getProjectTypeKey().getKey())
<h3>Heading injected into $issue.getKey()</h3>

#set ($commentList = $allComments.getComments($issue))
#if ($commentList.size()>0)
    #foreach ($comment in $commentList)
        #set ($commentAuthor = $comment.getAuthorApplicationUser())
        #if ( ($projectType=="software" && !$comment.getRoleLevel() && !$comment.getGroupLevel())
              || ($projectType=="service_desk" && !$jemhUtils.isPrivateJSDComment($commentAuthor,$comment)) )
            
            #set ($javaDateFormat = $applicationProperties.getDefaultBackedString("jira.date.picker.java.format"))
            #set ($formatter = $jemhDateUtils.getFormatter($javaDateFormat))
            <h3>Comment <small>$commentAuthor.getDisplayName()</small> added on - $dateFormatter.format($comment.getCreated())</h3>
            <p>$wikiRenderer.render($comment.getBody(),null)</p>
        #end
    #end
#else
    There are no public comments
#end

Output

Example JSM Issue with internal comment

image-20250213-091113.png

Preview of the template (excludes the internal comment)

image-20250213-091156.png
  • No labels