I want send an email when the value of a custom field changes. I have created a Script Listener to do this on Issue Updated but want to include the old value in the e-mail. How do I do this?
Currently I have:
Condition: changeItems.any {it.get('field')=='Numeric Priority'}
E-Mail Template:
Issue: $issue - ${issue.summary}
New Numeric Priority: <% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("Numeric Priority")) %>
User: $currentUser.name
Description: ${issue.description}
I want to add Old Numeric Priority.
Thanks
Hi James:
Since this is an Updated Issue Listener, it is recomendable to use this code
/*Gather changed field at the Issue Updated*/ def field = event.getChangeLog().getRelated('ChildChangeItem').find{it.field == "field_name"}; /*Gather field old value*/ def old_field_value = field.oldstring; //Old String of the field /*Gather field new value*/ def new_field_value = field.newstring; //New String of the field
Hope that this piece of code may help you
This sounds like this is what I am looking for. How do I use the above to extract the value into the e-mail template notation? Or is there another way to extract the value using what you have given me and append it to the e-mail?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
James:
I have to confess that I didn't handle on notifications. But, if you want to send the old value to the notification template, you might ending up with a java class.
Good luck
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I tried to use the nice code example above and incorporate it with a listener, but I cannot get it to work. Any ideas what I am doing wrong? {code:title=ExampleListener.groovy|borderStyle=solid} package com.acme.listener import com.atlassian.jira.event.issue.AbstractIssueEventListener import com.atlassian.jira.event.issue.IssueEvent import org.apache.log4j.Logger class ExampleListener extends AbstractIssueEventListener { Logger log = Logger.getLogger("log4jLogger") @Override void workflowEvent(IssueEvent event) { log.debug "Custom Issue Update Event Listener Fired" /*Gather changed field at the Issue Updated*/ def field = event.getChangeLog().getRelated('ChildChangeItem').find{it.field == "Priority"}; /*Gather field old value*/ def old_field_value = field.oldvalue; //Old String of the field /*Gather field new value*/ def new_field_value = field.newvalue; //New String of the field if ((new_field_value == 1).and(old_field_value != 1)) { log.debug "Custom Issue Update Event Listener Fired - Changed to J0" } else { log.debug "Custom Issue Update Event Listener Fired - Changed to some other priority" } } } {code} Thx :-)
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.