Need to fire event based on value change of custom field

Basically what I need is below

I have a custom field 'Special' with values None, A and B as drop-down option. By default the option is set as NONE. A user could change option A or B. When someone choses a value to A or B, an email needs to be send out accoridngly to a fixed email chain.

Need to send out Issue ID and Summary for the issue in the email as well as the current user who set it.

How can I accomplish this?

I tired behaviour plugin as described in this post and also used Mizan's option but think I am don't have the requisite background to code this. Apreciate any help

https://answers.atlassian.com/questions/67193/send-e-mail-notification-after-editing-a-specific-custom-field-in-issue-edit-screen

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 Special= getFieldById('11240')
ComponentManager componentManager = ComponentManager.getInstance()
MailServerManager mailServerManager = componentManager.getMailServerManager()
SMTPMailServer mailServer = mailServerManager.getDefaultSMTPMailServer()
  
if (mailServer) {
     
        Email email = new Email("someuser@example.com") // 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.
        email.setBody(content)
        mailServer.send(email)
     
}
else {
    log.error("No SMTP mail server defined")
}

1 answer

1 votes
Mizan Community Champion Dec 16, 2013

Hi Rizwan ,

Use the exact script provided by me .. use fieldChanged instead of your customfield id .

Also the script is for an older version of Jira , there are some api changes which you will need to update . eg: ComponentManager -> ComponentAccessor .

IF you use the above script then it will send an email whenever the user changes the value of the field before submiting it . I think you should use a post function , may be you can use send custom email post function by script runner plugin

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 ...

3,110 views 13 19
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