Hello!
I'm trying to add Linked issues information to Notification template.
Below is what I thought should be working:
#set ($linkedIssues = $issueLinkManager.getOutwardLinks($issue.getId()))
#if($linkedIssues)
#foreach($link in $linkedIssues)
#if($link.getIssueLinkType().getName() == "Link type name")
#set ($linkParent = $link.getDestinationObject())
#if($linkParent)
#set ($linkParentIssueType = $linkParent.getIssueTypeObject())
#set ($linkParentKey = $linkParent.getKey())
#set ($linkParentSummary = $textutils.htmlEncode($linkParent.getSummary()))
#set ($linkParentIssueIcon = "<a href='${baseurl}/browse/${linkParentKey}'>#renderIssueTypeIcon(${linkParentIssueType})</a>")
#set ($linkParentIssueLink = "<a style='color:${textLinkColour};text-decoration:none;' href='${baseurl}/browse/${linkParentKey}'>${linkParentKey} ${linkParentSummary}</a>")
Label text: $linkParentIssueIcon$linkParentIssueLink
#end
#break
#end
#end
#end
But it's not. $linkedIssues is always empty.
I've tried to add a specific declaration of issueLinkManager via ComponentAccessor as follows:
#set ($componentAccessor = $ctx.get("jirautils").loadComponent("com.atlassian.jira.component.ComponentAccessor", $ctx.getClass()))
#set ($issueLinkManager = $componentAccessor.getIssueLinkManager() )
But it still doesn't work.
I would be very grateful for any tips!
Maybe there is a way to get links directly from $issue within Velocity context?
Can you debug it and render the $issueLinkManager and $componentAccessor values so we see if they're not null? Based from what I see on the net your idea should work there. So I am also curious as to whether $linkedIssues is actually null, or whether it's an empty list (in which case we know where the problem is).
Are you modifying this in a template from /secure/admin/EmailTemplatesSettings!default.jspa or something custom / plugin? I'm curious whether there is an option you can provide java objects to the template instead of trying to obtain them from the template, I know you can do this in a plugin and add your own classes to your vm template, but unsure if that can be done with anything from the UI or wherever it is you are modifying this in.
Hi Radek! Thanks for the response.
I thought about it afterwards as well and checked it. Indeed $issueLinkManager and $componentAccessor are always null...
Also found a good description of available objects within Velocity context: https://developer.atlassian.com/server/jira/platform/jira-templates-and-jsps/
There is no IssueLinkManager in it, hence it doesn't work on its own.
And I'm at sea at the moment on how to load ComponentAccessor properly. Few examples from community that I found are not working.
I'm customizing regular email templates. Plugins are a little too advanced for us at the moment, so we are trying to use regular instruments (and ScriptRunner if it's otherwise impossible to do).
As a workaround I think about adding a scripted custom field with linked issues.
But it's a major letdown as I was planing to use customized templates extensively, being under impression that ComponentAccessor is available if needed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.