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

1 vote
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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

318 views 3 11
Read article

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