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 vote
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 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 Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

78 views 0 5
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