Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

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:

PropertyDescriptionValue

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 commentMessage ID, for example: <f97nfg4b4545f+f455hkjh632gnd@mail.example.com>

profileId

The JEMH profile ID number that processed the commentNumber, for example: 1
reporterIsDefaultReporterIs 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

toThe email address of the comment "to" recipient

CSV Email addresses, for example: u1@x.com,u2@y.com

ccThe email address list of the comment "cc" recipientsCSV Email addresses, for example: u3@x.com,u4@y.com
com.ppl.jsd.public.commentIs the comment a JSD public commenttrue 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:

#set ($commentToShow = "")
#set ($lastComment = $allComments.getLastComment($issue))
#set ($commentSender = $jemhUtils.getCommentProperties($lastComment).getProperty("from"))
#set ($isNonJira = $jemhUtils.getCommentProperties($lastComment).getProperty("sentByNonJiraUser"))
#if ($commentSender && $isNonJira)
 This is the last Non-JIRA user comment. It was made by $commentSender:
 $lastComment.getBody()
#else
There are no comments to show
#end

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 would need to have a condition that search for any 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

/code

Related Articles

  • No labels