Prevent /inhibit sending of a notification (Issue Event or Postfunction)


From version 1.7.2, JEMH has the ability to allow scripted decision logic at the Template level on whether or not a given notification should be sent by using the $jemhUtils.setInhibitSending(boolean) method.  The script itself can be as simple or complex as you need.

Template Sets are the raw Velocity mark-up content for email notifications.  For more information on what Velocity is and how it is used, see the official user guide here.

Project Mapping Solution

If you do not want to customize templates, it is possible to add inhibition logic at the ProjectMapping config level, see:


The Velocity Context

The usual velocity context references are available to help you script your decision logic, there is also a helper class available $jemhUtils , see the API link below for additional methods available:


Before using the setInhibitSending(boolean) method, you will want to set up the overlying conditions for when this should happen.  Lets imagine I don't like SIMPLE-11 as an issue key, and want to prevent all notifications about that issue.  Note that your condition does not have to be based on the issue key - it could be based on almost anything (e.g. priority, custom field values, statuses, day of the week).

Basic Logic
#if ($issue.getKey()=="SIMPLE-11") ##inhibit #end #if ($issueEvent.getEventTypeId().longValue()==1) ##inhibit for ISSUE_CREATED #end

Inhibiting the notification


The above line will set the boolean isInhibitSending to true. If after the template rendering is complete, this boolean is found to be true then the notification will not be queued for sending.  If needed, you could potentially want to reset the boolean back to false in the template also - however if your logic is set out efficiently this may not be needed.

Setting a reason for inhibition

The below line would set the reason for preventing sending of the notification to JEMH's jemh.log file (if logging is enabled).

$jemhUtils.setInhibitSendingReason("I dont like number 11")

Implementing in your template

You may wish to consult the built-in Velocity context list in order to know what classes and variables are available for you out-of-the-box.  This can be found by going to JEMH>Template Sets and expanding the Velocity Context section.  Here is our example in its full glory:

Resulting jemh.log output

The jemh.log (see