Send E-mail Notification after editing a specific custom field in issue edit screen

Hi there,

I've been looking around for a while and can't find a real solution. We have implemented a custom field called "supervisor" (user picker). As sonn as someone changes the value of that field (selects another supervisor) I need an e-mail sent to the new supervisor.

Those are the posts I've found so far:

As far as I can tell the problem is mainly being addressed via post-functions as part of the groovy script plugin.

The problem is, that I would need a transition to fire an event, a post-function etc. My customer wants the email to be sent right away without the need of a workflow transition. Would it be possible to execute the code provided in Jamies examples of the script runner using the behaviours plugin (in real time) ?

Thanks for any hints...

Cheers Christian

3 answers

1 accepted

I think you need to use the send email listener with a condition that the field has changed, and is the value you want to check for.

Using the behaviours plugin is all well and good, but it will send the mail as soon as the value is changed, and before the issue is even saved. I know they wanted it sent "as soon as" but that's overkill. If they toggle it multiple times then multiple emails will be sent.

Hey, thanks for the advice. I've never created a listener. Are those the right places I have to start from? Or can I modify an existing listener?



Yup, those are the ones!

My solution to notify someone when a custom JIRA field is modified is to use the Filter and Subscriptions.

E.g. If I needed a notification sent out whenever our custom field ‘Test Notes’ is updated, I would create a filter such as says ‘Test Notes Updated in last 1 hour’ with following search criteria

 "Test Notes" is not EMPTY AND updated > -1h

 Next, save the filter. Search your saved filter in Manage Filters. Click Subscribe under Subscriptions column. Add subscription using the on screen options for Recipients, Schedule, Interval etc. If you need one or more people to receive the notifications, create a JIRA group under JIRA User Management options / Groups tab on the left. e.g. jira-testers: Once you add the subscription, that’s it, it is not instantaneous as you are asking it to notify everything updated in last one hour (1h in the filter above) but you can make it so if you want by changing your filter.


I think this is possible using Behaviours you will just need to paste the same script with some additional packages provided by behaviours plugin as a server side script on the "supervisor" field.

This script will get fired whenever the supervisor field is changed.

Note : it will even get fired if someone changes the field and again change the field and everytime when changing the field before submitting

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.mail.Email
import com.atlassian.mail.server.MailServerManager
import com.atlassian.mail.server.SMTPMailServer
import org.apache.log4j.Category

FormField supervisor = getFieldById(fieldChanged)
ComponentManager componentManager = ComponentManager.getInstance()
MailServerManager mailServerManager = componentManager.getMailServerManager()
SMTPMailServer mailServer = mailServerManager.getDefaultSMTPMailServer()
if (mailServer) {
        Email email = new Email("") // Set the TO address, optionally CC and BCC
        email.setSubject("Blocking issue raised by ${issue.getReporter().getFullName()}: ${issue.summary}") // todo: check the subject value
        String content = "Construct your body here.";  //TODO: Set email's body.
else {
    log.error("No SMTP mail server defined")

Try the above script , enable logging .

I'll try the script tomorrow. Thanks! Just one more thing:-) The Email TO-address in this example is static. I'd need to dynamically populate that with the newly selected supervisor's mail address. Any ideas?

I dont think that will be a big challenge we will have to get the value in the supervisor field then get the email id of that user , first test with a static email id .

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 13, 2019 in Jira

Make your Atlassian Cloud products more secure: our NEW admin security guide

Hey admins! I’m Dave, Principal Product Manager here at Atlassian working on our cloud platform and security products. Cloud security is a moving target. As you adopt more products, employees consta...

620 views 0 12
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