Send email on asignee change

IT Support September 17, 2013

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

1 vote
Answer accepted
Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 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