Add additional recipients via Velocity for Issue Events and Post Function Notifications

Scenario

As part of an Issue Event, Post-function, or Ad-Hoc notification, you may want to automatically update specific email addresses based on the state of the issue. For example, you may want to conditionally notify a group if an issue is a specific type, or a single user if the issue has been moved to a 'Blocked' status. Adding additional recipients can be achieved as part of a notification template using the jemhUtils 'addRecipients’ methods.

Add Recipients Methods

The jemhUtils class includes six add recipients methods, separated into two groups of three which are used separately for Issue Event Notifications, and Post-Function Notifications.

Using methods designed for Issue Events on a Post Function Notification will result in the address being ignored and visa versa

Issue Event Add recipients methods:

Examples

$jemhUtils.addIndividualRecipientAddress("address1@test.com, address2@test.com, sender@test.com"); $jemhUtils.addIndividualRecipientGroup("individual-recipient-group"); $jemhUtils.addIndividualRecipientUser("user1@test.com");

Post Function / Ad-Hoc Notification Add Recipient methods

Examples

$jemhUtils.addRecipientAddress("to", "address3@test.com"); $jemhUtils.addRecipientGroup("cc", "recipient-group"); $jemhUtils.addRecipientsFromRole("cc", $issue.key, $issue.getProjectObject(), "Service Desk Customers")

Application

The following details how each method can be used to notify additional recipients:

Issue Event Add recipients methods:

Using these methods It is possible to notify Jira users from an Email only user template and visa versa. In these scenarios the template, and notification configuration which included the method will be used to notify the recipient in question. i.e. If you add a User from a Non-Jira user notification, the user will receive a Non-Jira user notification.

addIndividualRecipientAddress​(String addressCsv)

Parameters/Arguments:

  • String addressCsv: A Comma separated value of each address that should be notified, e.g. test1@test.com,test2@test.com,test3@test.com

This method creates a new email for each recipient in the list using the same template that the recipients were added in (without generating new recipients).

addIndividualRecipientGroup​(String groupName)

Parameters/Arguments:

  • String groupName: The name of the group that should be notified

This method creates a new email for each member of the group using the same template that the recipients were added in (without generating new recipients).

addIndividualRecipientUser​(String username)

Parameters/Arguments:

  • String username: The username of the user that should be notified

This method creates a new email for the user associated to the username provided in the method using the same template that the recipients were added in (without generating new recipients).

Post Function / Ad-Hoc Notification Add Recipient methods

addRecipientAddress​(String recipientType, String addressCsv)

Parameters/Arguments:

  • String recipientType: The type of recipient the recipient should be added as i.e ‘To’, or ‘Cc’

  • String addressCsv: A Comma separated value of each address that should be notified, e.g. test1@test.com,test2@test.com,test3@test.com

This method adds each listed address to the recipient header defined as a parameter.

addRecipientGroup​(String recipientType, String groupName)

Parameters/Arguments:

  • String recipientType: The type of recipient the recipient should be added as i.e ‘To’, or ‘Cc’

  • String groupName: The name of the group that should be notified

This method adds each member of the group to the recipient header defined as a parameter.

addRecipientsFromRole​(String recipientType, String issueKey, com.atlassian.jira.project.Project project, String roleName)

Parameters/Arguments:

  • String recipientType: The type of recipient the recipient should be added as i.e ‘To’, or ‘Cc’

  • String issueKey: The issue Key of the issue involved in the Notification

  • com.atlassian.jira.project.Project project: The Jira Project that the notifications should be role members of

  • String roleName: The name of the project role that should be notified, e.g. Service Desk Customers

This method adds each member of the group to the recipient header defined as a parameter.