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

2 answers

1 accepted

1 votes

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!

0 votes
Mizan Community Champion Jul 04, 2012

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

Mizan Community Champion Jul 04, 2012
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?

Mizan Community Champion Jul 04, 2012

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,855 views 12 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot