Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Someone knows if you can throw an event with script runner and process mails with Email this Issue


I need to throw an event with script listener on an issue updated event. Then afterwards, the event should be processed by Email this Issue with a given Template. In Email this Issue I already uploaded a template, notification and a context for this event.

I tried everything to throw an event but no mail gets sent and I don't know why nor can I figure out why in logs. I tried following code already to throw an event:

First try:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption;

def aGroupChanged = event.changeLog.getRelated("ChildChangeItem").find { it.field == "aGroup" }

if (aGroupChanged) {"(" + event.issue.key + ") E-Mail gets sent")
ComponentAccessor.issueEventManager.dispatchEvent(10100L, event.issue, event.user, true)

Since this method is deprecated i tried something else, which I found in the community and modified it a bit:

import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.issue.IssueEventBundle
import com.atlassian.jira.event.issue.IssueEventManager
import com.atlassian.jira.event.issue.IssueEventBundleFactory
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventDispatchOption;
import org.apache.log4j.Category;

Long EVENT_ID = new Long("10100")
ApplicationUser currentUser
IssueEventBundle eventBundle
def aGroupChanged = event.changeLog.getRelated("ChildChangeItem").find { it.field == "aGroup" }

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

currentUser = jiraAuthContext.getLoggedInUser()
eventBundle = issueEventFactory.wrapInBundle(new IssueEvent (event.issue, null, currentUser, EVENT_ID))

if (aGroupChanged) {
issueEventM.dispatchEvent(eventBundle)"Issue: " + event.issue.key + " E-Mail sent");
} else if (!aGroupChanged) {"Issue: " + event.issue.key + " ERROR");

Some advices? Since I don't script or code very much I don't know what to do next, especially in the 2nd try, which is too complicated already for me. Thanks in advance

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Online AMA this week: Your project management questions answered by Jira Design Lead James Rotanson

We know that great teams require amazing project management chops. It's no surprise that great teams who use Jira have strong project managers, effective workflows, and secrets that bring planning ...

196 views 1 6
Read article

Atlassian Community Events