Customize Templates based on recipient project role membership
Scenario
You want your templates to be different depending on whether a recipient of the notification is a member of a particular JIRA project role.
Configuration
The following velocity script will render different content depending on the whether or not the recipient is a member of a certain project role (in this example whether or not they are a member of the Service Desk Customers role). This script can be adapted into a user macro which will make the maintenance of the script easier and quicker.
To change the role the script is check for, replace the "Service Desk Customers" with "YOUR PROJECT ROLE".
#if($allRoles.isUserInProjectRole($recipientUser,$allRoles.getProjectRole("Service Desk Customers"),$issue.getProjectObject()) == true)
Hello there Customer
#else
Hello there Agent
#end
Additional Recipients
@since 2.1.13
In 2.1.13 we add some more helper methods in $jemhUtils, to enable scripted recipient inclusion.
$jemhUtils.addRecipientsFromRole("TYPE", "ISSUE-KEY", project, "ROLE_NAME")
$jemhUtils.addRecipientAddress("TYPE", "ADDRESS_CSV")
$jemhUtils.addRecipientGroup("TYPE", "GROUPNAME")
addRecipientFromRole
This method appends all Actor users found within the given role to to notification being rendered. NOTE: the project
parameter is the project object:
$jemhUtils.addRecipientsFromRole("to", $issue.getKey(), $issue.getProjectObject(),"Developers")
addRecipientFromAddress
This method appends the given recipients to outbound notification being rendered. Recipients can only be smtp addresses of format XXXX@YYYY, additional recipients may be listed, using comma as a separator:
addRecipientGroup
This method appends all members of the given group to outbound notification being rendered. No consideration is given to whether the user is otherwise listed as a recipient:
Editing the Workflow Postfunction
The postfunction has a Mail Header Velocity Script.
When the Preview Context issue is set at the top, you can validate the logic you use to determine if the inclusion will work or not (here we just show the related issuekey and project)
About $issue
$issue is a TemplateIssue, see the docs for available methods.
Edit Time
Preview
When an issuekey is in context, you can preview, here to show that the project object is actually present:
Edit an Ad-Hoc Notification
Ad-Hoc notifications can be customized with velocity. You may want to send an Ad-Hoc notification to members of a project role for example.
Enable the advanced Content Editor so you can modify velocity
Customise velocity content to notify members of a project role
Related Articles
-
Questions:
-
-
-
Questions:
-
Questions: