Send email on asignee change

Hey guys,

I've got a configuration query, which hopefully someone is able to answer!

It seems that in the latest version of JIRA, in-line editing is considered an "issue update". E.G., if you change the asignee via in-line editing, it will not register as an "issue assign" task, where it normally would email both the current and the last asignee.

We've disabled email on issue update due to the stupendous amount of emails that we received every time the ticket was created, issue type changed, priority changed, etc etc etc.

I was wondering if anybody had a script for a listener so that it can listen for an inline assign task, and email both the current and the last assignee that the ticket has been modified (just as if you clicked the "assign" button).

Help!

Thank you in advance

1 answer

1 accepted

This widget could not be displayed.
Henning Tietgens Community Champion Sep 17, 2013

You can use the Script Runner plugin and a script listener like this.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.issue.IssueEventManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.ApplicationUsers
import org.apache.log4j.Logger

import static com.atlassian.jira.event.type.EventType.ISSUE_ASSIGNED_ID

class AssigneeListener extends AbstractIssueEventListener {
    Logger myLog = Logger.getLogger(AssigneeListener.class)
    IssueEventManager issueEventManager = ComponentAccessor.getIssueEventManager()

    @Override
    void workflowEvent(IssueEvent event) {
		// only one central way...
		this.customEvent(event)
	}
	
    @Override
    void customEvent(IssueEvent event) {
        // If the assignee was changed...
        if (event?.changeLog?.getRelated('ChildChangeItem')?.any{ it.field=='assignee' }) {                         
            myLog.debug "Assignee was changed, triggering ISSUE ASSIGNED event."
            ApplicationUser user = ComponentAccessor.jiraAuthenticationContext.getUser()
            issueEventManager.dispatchEvent(ISSUE_ASSIGNED_ID, event.issue, ApplicationUsers.toDirectoryUser(user), true)
        }
    }
}

The code is for JIRA 6 and not tested, so please test on a test system first. See https://jamieechlin.atlassian.net/wiki/display/GRV/Listeners for installation instructions for custom groovy listener.

Henning

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

303 views 1 4
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you