Use Comment Entity Properties in Custom Notfication Templates
Since version 1.9.8
Scenario
It may be desirable to use the Comment Entity Properties that JEMH sets on comments that it creates. For instance, you may wish to use the address of the Non-JIRA user sender in your notification template.
Usage in Custom Templates
As of JEMH 1.9.8, JEMH's comment entity properties can be accessed via Velocity templates. This exposes several comment properties:
Property | Description | Value |
---|---|---|
sentByNonJiraUser | Was this comment sent by a Non-JIRA user? | Boolean value (true or false) |
messageId | The message ID of the email that resulted in this comment | Message ID, for example: <f97nfg4b4545f+f455hkjh632gnd@mail.example.com> |
profileId | The JEMH profile ID number that processed the comment | Number, for example: 1 |
reporterIsDefaultReporter | Is the comment created by the Default Reporter? | Boolean value (true or false) |
from | The email address of the comment sender | Email address, for example: sender@example.com |
to | The email address of the comment "to" recipient | CSV Email addresses, for example: u1@x.com,u2@y.com |
cc | The email address list of the comment "cc" recipients | CSV Email addresses, for example: u3@x.com,u4@y.com |
com.ppl.jsd.public.comment | Is the comment a JSD public comment | true if so, otherwise not defeined. |
The above property values are retrieved by calling $jemhUtils.getCommentProperties(<comment object here>).getProperty("<property>"). For example:
$jemhUtils.getCommentProperties($comment).getProperty("profileId")
Velocity Template Example
Here is a small text format that uses the sentByNonJiraUser and from comment entity properties. This takes the last comment made by a Non-JIRA user and then displays the senders email address, and the comment itself:
#set ($commentList = $allComments.getComments($issue))
#set ($commentToShow = "")
#if ($commentList.size()>0)
#foreach ($comment in $commentList)
#if ($jemhUtils.getCommentProperties($comment).getProperty("sentByNonJiraUser") == "true")
#set ($commentToShow = $comment)
#end
#end
This is the last Non-JIRA user comment. It was made by $jemhUtils.getCommentProperties($commentToShow).getProperty("from"):
$commentToShow.getBody()
#else
There are no comments to show
#end
In this example, the resulting template output is this:
This is the last public comment. It was made by admin (on behalf of andy@localhost):
This is a comment made by a non-JIRA user. Hello!
Want the last comment regardless of who sent it?
Alternatively, the following will show the last comment, only if it is a non-JIRA user who sent it:
Inhibit Notifications if comment was added using an incoming email from JEMH
If you would like to inhibit notifications for all comments that JEMH adds, then you can by having a condition that searches for any JEMH Comment Properties that have been added and if found then it would mean that JEMH added the comment and should be inhibited.
Below is an example script that can be used within Issue Event templates
Related Articles
-
-
-
Questions:
-
Questions:
-