/
Injecting comments

Injecting comments

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

Ad hoc usage

Script is accessed through Insert > Templates, then select from the rendered templates:

Once in the content, that it, its merged: