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:
https://answers.atlassian.com/questions/16652/trigger-email-based-on-custom-field-value
http://old.nabble.com/trigger-email-based-on-custom-field-value-td29452403.html
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
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?
https://confluence.atlassian.com/display/JIRA/Listeners
Cheers
Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yup, those are the ones!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
SK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your solution is not triggered by an event. The email will send anyway - based on pre-set schedules - whether the update of last hour does or does not occurs.
In other words, if there was no change took place in the last hour, the email notification will send anyway.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
John, there is an option to disable sending the email if the query has no results.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
8 years later, if you are looking for an easy way to handle this without having to write custom listeners, Notification Assistant for Jira supports sending notifications on Field Edit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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("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") }
Try the above script , enable logging .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.