Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Configuring custom Issue Events to generate useful notifications

Lionel Cassin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 23, 2020

The Need: When a specific custom field is changed ("assignedTeam"), an email is sent to all members of the group listed in a group custom field (single select).

My Method: 

  1. Wrote a custom listener in Scriptrunner that listens for Issue Updated.  If that script detects a change in assignedTeam, then the script creates a new eventBundle and dispatches it as a custom Event with an ID of 10300 (code excerpt below).
  2. My notification scheme catches that custom Event and sends a notification to various users.

The Problem:

  1. Almost everything works perfectly.  The script catches the change in assignedTeam, fires the event, the notification scheme catches the event, creates the email, and sends it to all the right people.
  2. BUT the email does not show which fields were changed and the old/new values: bad update.png
  3. In contrast, this is what a "normal" update notification looks like and what I want mine to look like:good update.png

I think my mistake is in the construction of the issueEvent/eventBundle (below).  I think there should be some way to pass the change log to the constructor, but I just can't figure it out.  Thanks.

Listener code:

if assignedTeam has changed...

{
Long EVENT_ID = new Long("10300")

IssueEventManager issueEventM = ComponentAccessor.getIssueEventManager()
IssueEventBundleFactory issueEventFactory = (IssueEventBundleFactory) ComponentAccessor.getComponent(IssueEventBundleFactory.class)

IssueEventBundle eventBundle = issueEventFactory.wrapInBundle(new IssueEvent (issue, null, event.user, EVENT_ID, true))
issueEventM.dispatchEvent(eventBundle)
}

0 answers

Suggest an answer

Log in or Sign up to answer