Link to an issue via JSD customer portal in a custom notification template


The following configuration requires an understanding of how to use custom notification templates in JEMH.  The wiki page for this information can be found here: Customize Email Templates.  Also, it is recommended that you have a basic understanding of how VTL (Velocity Template Language) is used.  Please refer to the Apache Velocity User Guide.


The following velocity template will check if the notification recipient is in the customer project role.  If they are, it will render an HTML link that when opened, directs the user to the customer portal view of the issue that the notification is referring to.  If they are not in the customer project role, they will be shown a link to the standard JIRA issue:

#set ($roleList = $allRoles.getProjectRoles()) #foreach ($role in $roleList) #if ($role == "Service Desk Customers") #if ($allRoles.isUserInProjectRole($recipientUser,$role,$issue.getProjectObject())) <a href="${baseurl}/servicedesk/customer/portal/1/${issue.getKey()}">${issue.getKey()}</a> #else <a href="${baseurl}/browse/${issue.getKey()}">${issue.getKey()}</a> #end #end #end

If you have multiple service desks, the service desk number in the URL will be different for each one.  If you only have one service desk, this should be using the number "1".  The below JSD API methods may be used to get the portal id dynamically.


Since JEMH v1.9.16, the following new JSD related API is exposed, your templates should be nullsafe here, if JSD is disabled, or inaccessible, a null value will be returned.


Test for a null value by using:

#if ($!jemhUtils.getJsdApi()) your code here #end

The API exposes the following methods:

Its therefore possible to query based on a given issues $issue.getProjectObject() and $receipientUser, to get the numeric portal ID that is hard coded above.

Using the JSD API methods defined above it is possible to include a dynamic hyperlink within an issue notification that will link to the correct customer portal that relates to the issue. The following code will output a link the correct customer portal for the associated issue if the user is within the Service Desk Customers role and the JSD API is accessible. If neither of these conditions are met a fallback link is generated to the issue directly.

JEMH doesn't yet expose documentation of its own utility and API classes,