Customize Message Rejection Notifications
Selecting a message rejection notifications template
The template set that is used to create message rejection notifications can be selected via Project Mapping → Templates → Message Rejected Template Set:
Customizing message rejection templates
Like other notification templates in JEMH Cloud, the rejection templates make use of the Apache Velocity templating language. The template has a context associated with it during render, which carries all the data related to the thing being notified about. In this case, the context contains data about the email being rejected, and why it was rejected.
Accessing the template context
To access the context from within the template code, use the $context
variable. This variable is actually a https://www.javadoc.io/static/com.fasterxml.jackson.core/jackson-databind/2.18.3/com/fasterxml/jackson/databind/node/ObjectNode.html object that represents JSON data.
Conditionally show content based on email rejection cause
Available rejection causes
CANNOT_COMMENT_CLOSED_ISSUE
CANNOT_COMMENT_LIMIT_REACHED
CANNOT_COMMENT_RESOLVED_FOR_LONGER_THAN_DAYS
CANNOT_COMMENT_USER_DOES_NOT_HAVE_PERMISSION
CANNOT_COMMENT_EMAIL_NOT_INVOLVED
CANNOT_CREATE_ISSUE_WHEN_COMMENT_ONLY_MODE
ISSUE_CANNOT_BE_CREATED
REJECT_COMMENT_ON_STATUS
REJECT_COMMENT_ON_JQL
The email reject cause, along with the default rejection subject and body content, can be found via 3 context properties:
Template (Text) | Output |
---|---|
## the type of rejection that caused this notification
$context.messageRejectedCause
## the default subject content
$context.messageRejectedSubject
## the default body content
$context.messageRejectedMessage | "CANNOT_COMMENT_CLOSED_ISSUE"
"This is the subject of the reject message"
"This is the reason why the message has been rejected" |
Template (HTML) | Output |
---|---|
<p style="font: bold italic large serif">
#if ($context.messageRejectedCause.asText().equals("CANNOT_COMMENT_CLOSED_ISSUE"))
The issue $!context.issue.key.asText() can't be commented on, please <a href="https://example.com">go here instead</a>.
#end
</p> | The issue SSD-190 can't be commented on, please go here instead. |