@since 1.8.20
The DefaultIssueLinkService class is now exposed for use via Velocity Template Language (VTL). This allows JEMH's custom templates to make use of this service in order to display the linked issues of an issue in notifications.
Firstly, we will set up the custom Velocity macro. The reason for creating a macro, rather than just adding the velocity code directly into a template itself, is that if you wish to make a change, this can be done in one place instead of having to do it for all templates where the code is used.
Click Edit on the User Macros tab
Copy the below macro to the bottom of your user macros list
The macro provided below is an example, showcasing how the exposed service can be used and can of course be modified to meet the users needs. |
#macro (issuelink) #set ($test = $issueLinkService.getIssueLinks($actionUser,$issue)) #set ($linkCollection = $test.getLinkCollection()) #if ($!linkCollection && $linkCollection.getAllIssues().size()>0) <tr> <th> Issue Links: </th> <td> <table> #foreach( $linkType in $linkCollection.getLinkTypes() ) #set ($inboundIssues = $linkCollection.getInwardIssues($linkType.getName())) #set ($outboundIssues = $linkCollection.getOutwardIssues($linkType.getName())) #set ($outboundSize = $outboundIssues.size()) #set ($inboundSize = $inboundIssues.size()) #if ($inboundSize>0 || $outboundSize>0) <tr> #if ($inboundSize>0) <td> $linkType.getInward() </td> #foreach ( $anIssue in $inboundIssues) <td><a href="${baseurl}/browse/${anIssue.getKey()}">$anIssue.getKey()</a> [$anIssue.getStatus().getSimpleStatus().getName()] </td> #end #end </tr> <tr> #if ($outboundSize>0) <td> $linkType.getOutward() </td> #foreach ( $anIssue in $outboundIssues) <td><a href="${baseurl}/browse/${anIssue.getKey()}">$anIssue.getKey()</a> [$anIssue.getStatus().getSimpleStatus().getName()] </td> #end #end </tr> #end #end </table> </td> </tr> #end #end |
With the custom user macro saved, we can now call the macro in our custom notification template. In this guided example, we will add the issue links to an Ad-Hoc Notification template.
@since 3.3.40
The Issue Links field can also store external links to webpages, or integrated Confluences instances. The DefaultIssueLinkService only supports links to Issues in the same Jira instance. To add external links to an email template the 'remoteIssueLinkService ' should be used.
The following script can be used to retrieve external links and display them in a notification:
#if($remoteIssueLinkService.getRemoteIssueLinksForIssue($actionerUser, $issue).getRemoteIssueLinks().size() > 0) True! Links found. #set($foundLinks = $remoteIssueLinkService.getRemoteIssueLinksForIssue($actionerUser, $issue).getRemoteIssueLinks()) #foreach($remoteLink in $foundLinks) $wikiRenderer.render($remoteLink.getTitle(),null) $wikiRenderer.render($remoteLink.getUrl(),null) #end #else False! No links found. #end |
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
|