Email notification when assignee changed

Jst November 23, 2018

On the forum I saw a bunch of posts that explain how to setup an event listener and add this to the transition of the project's workflow. My goal is to do almost the same. I would like to sent an email to a custom email address when the assignee field is changed from unassigned to a person and also from a person to unassigned. The problems I faced when using solutions from other forum topics:

1) When using issue.assignee != originalIssue.assignee the event only seems to trigger from unassigned to assigned, but not on assigned to unassigned. Could be a Script Runner issue or improperly configured by me.

2) The Send a custom email was configured in the addon section, but when later trying to add it to a transition, I am unable to select the pre-configured event. The fields are all blank and it looks like I would need to configure this addon each transition post event. I have about 30 transitions :)

3) Is there no way to specify the project and sent an email based upon the assignee field changing generally? Because there will be cases where there is no transition upon changing the assignee. I have a project based on this guide: https://www.atlassian.com/blog/jira-service-desk/free-ebook-jira-service-desks-guide-asset-management

Any suggestions are very welcome!

Jira version: v7.1.7#71011

1 answer

1 accepted

1 vote
Answer accepted
Elifcan Cakmak
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.
November 23, 2018

Hello,

I assume you are using script runner for this purpose. 

When you configure a Send a custom email script listener, you don't need to add it to your transitions. Script listener, as the name suggests, listens to the events that you define and runs when that event occurred. What you are referring I presume is adding the event to your transition and than adding it to your notification scheme. Send a custom email is a script listener.

Regards,

Elifcan

Jst November 23, 2018

Well that is basically what I want, an even (Email) triggered without the use of transitions. That would be lovely. What about the first question? :) I noticed the event triggered twice when changing the assignee field 4 times. (2x unassigned to assigned, assigned to unassigned) 

Also it does not send an email although SMTP test emails arrive.

Thanks so far!!

Elifcan Cakmak
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.
November 25, 2018

Hello,

For the first question I think you need to write a custom script that uses change history manager. If you get the previous assignee and compare it to the current assignee, it should work from unassigned to assigned and vice versa.

https://docs.atlassian.com/software/jira/docs/api/7.1.7/com/atlassian/jira/issue/changehistory/ChangeHistoryManager.html

Why it doesn't send an email is probably related to the configuration of the script listener. I don't have enough info to guess why it is not working. You can check the email queue and the logs of the outgoing mails. See if it is trying to send the mail or there is no mail at all.

Regards,

Elifcan

Jst November 26, 2018

Hi Elifcan,

You definitely helped me a lot, it pointed me to a solution. It even sends out the mail!
I managed to find this after googling ChangeHistoryManager:

https://community.atlassian.com/t5/Jira-questions/ScriptRunner-Transition-Issue-based-on-Assignee-value/qaq-p/722115

From there I setup this script listener:

// Gather changed field at the Issue Updated
def field = event.getChangeLog().getRelated('ChildChangeItem').find{it.field == "assignee"}

field.newstring != field.oldstring

It listens to events: Issue Updated, Issue Assigned and Issue Reassigned

Elifcan Cakmak
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.
November 26, 2018

Hello,

I'm glad it helped :)

Regards,

Elifcan

Like Jst likes this

Suggest an answer

Log in or Sign up to answer