Enable Issue Created Notification for both Portal and JIRA Email Users (and prevent duplicate notifications)

Prevent duplicate issue creation notification for JIRA email users when notifying portal users.


In a JIRA Service Desk project you may wish to have both portal and JIRA email users notified of issue creation through the JEMH Event Listener.


Portal Users

To ensure that a portal user receives an Issue Created notification, navigate to your project mapping in the JEMH Event Listener and set the Notify me Condition setting to forSelectedEvents and then select the Issue created event in the Notify Me Events field. This will override any profiles My Changes setting if it has been set to Do not notify me, this done because it would otherwise result in the user not getting the Issue Created notification.

Then in the Event Template Selection section of the mapping, assign a template to the Issue Created event.

Email JIRA Users

The configuration needed to notify portal users can also be used to send Issue Created notifications to JIRA email users who email in to create tickets. However using this configuration means that other email addresses that need to be notified during issue creation (such as watchers etc) will not be notified since they are not set at the time the Issue Created notification is sent due to JEMH's historic two-phased issue creation processes (Phase 1 = issue is created, Phase 2 = all custom fields set and attachments are added etc).

In order to get around this we will have JEMH fire a custom event on issue creation as per the Create a JIRA Custom Event and Create a JEMH profile sections of the Configure JEMH for a Helpdesk environment from scratch guide.

Once a custom event has been made and is set to fire during issue creation, navigate back to your project mapping in the Event Listener. Now select your custom event in the Notify Me Events field like we did for theIssue Createdevent (hold down CTRL and then click the event to highlight multiple events).

Once the event has been selected assign a template to the event in Event Template Selection section of the mapping.

Preventing duplicate Issue Created notifications for email JIRA users

The issue now is that when an issue is created by a JIRA user via email, the reporter will now receive two notifications.

To stop this create a new text custom field. Once created navigate to the either the Custom Field Defaults section (removed as of JEMH 2.0.11) of your JEMH profile or your Default Project Mapping and add a default value of Email for the newly created field.

This will make it so that the new custom field will automatically be populated by JEMH during email issue creation. Then edit your project mapping in the JEMH Event Listener and the following script to the Event Selector and Filter script field:

#set($cf = $customFieldManager.getCustomFieldObject("customfield_10600")) #set ($cfValue = $issue.getCustomFieldValue($cf)) #if ($issueEvent.getEventTypeId() == "1" && $cfValue == "Email") $result.setIgnoreEvent(true) $result.setReason("Stop duplicate") #else Its normal, leave alone #end

You will need to replace the 10600 with the ID of your newly created custom field which can be found by navigating to JIRA Administration > Issues > Custom fields, after finding your field click on the cog for that field and mouse over the edit link, the URL preview will display ID.

Now when an issue is created via JEMH it will populate the newly created custom field with the value Email, when the Issue Created event is detected by the Event Listener it will check to see if the custom field has the value Email. If it is found to have the value then the notification will be dropped therefore stopping JIRA email users from receiving duplicate notifications during issue creation, if the value is not found the notification will be sent.