/
Customize Message Rejection Notifications

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.

{ "from": "someUser1@gmail.com", "recipients": [ "someUser2@gmail.com", "someUser3@gmail.com", "someUser4@gmail.com" ], "subject": "The subject of the orignal email", "body": "This is the body of the original email", "bodyFormat": "text", "messages": [ "INFO - Profile: id=64, Name=someUser2@gmail.com, Mapping=Default, Message Type=Test Case", "INFO - Watcher not set. JIRA user with email someUser3@gmail.com found but it doesn't have project permissions.", "INFO - Issue 'BSD-190' has been created.", "INFO - Watcher 'someUser4' added to issue.", "See file 'original-email.txt' attached." ], "higherType": "INFO", "issue": { "self": "https://somehost.atlassian.net/rest/api/latest/issue/18200", "key": "SSD-190", "id": 18200, "fields": { "status": { "self": "https://somehost.atlassian.net/rest/api/2/status/10003", "name": "Waiting for support", "id": 10003, "description": "This was auto-generated by JIRA Service Desk during workflow import", "iconUrl": "https://somehost.atlassian.net/images/icons/status_generic.gif" }, "issueType": { "self": "https://somehost.atlassian.net/rest/api/2/issuetype/10106", "id": 10106, "name": "Access", "description": "For new system accounts or passwords. Created by JIRA Service Desk.", "iconUri": "https://somehost.atlassian.net/servicedesk/issue-type-icons?icon=access", "subtask": false }, "project": { "self": "https://somehost.atlassian.net/rest/api/2/project/10001", "key": "SSD", "id": 10001, "name": "Some Service Desk Project" }, "summary": "The summary of the SSD issue" } }, "messageRejectedCause": "CANNOT_COMMENT_CLOSED_ISSUE", "messageRejectedMessage": "This is the reason why the message has been rejected", "messageRejectedSubject": "This is the subject of the reject message" }

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

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

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.

Default rejection notification examples

When issue is in specified status
When issue has been in resolved status for a number of days
When the issue comment limit has been exceeded
When project mapping’s operating mode is comment only
When email sender is uninvolved with issue

Related Articles

Related content