I have a field called "Escalated to Teams". This field is pre-populated with a value during an earlier transition. Later on in the workflow, this field appears on a screen during a transition and is changed by the user to a new value. Based on the value selected, I want an email sent to people associated with that value.
What I did was set up several listeners using scriptrunner. I chose the Send a Custom Email listener type and set the Events to Issue Updated.
The Condition and Configuration looks like this:
import com.atlassian.jira.component.ComponentAccessor
def issue = event.issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObjectByName("Escalated to Teams") // name of CF
def optionsManager = ComponentAccessor.getOptionsManager()
def fieldConfig = customField.getRelevantConfig(issue)
def option = optionsManager.getOptions(fieldConfig).find { it.value == "Dreamworks" } // value of option
def change = event?.getChangeLog().getRelated("ChildChangeItem").find {it.field == "Escalated to Teams"}
if (change) {
if (issue.getCustomFieldValue(customField) == option) {
log.debug("Found the correct option")
return true
}
}
I then set up an email template and subject template.
However, no email is being triggered during the transition. The transition validates the Escalated to Teams field is required. The Post Functions include that a generic event is fired. The only other thing I can think of is that I have a second scriptrunner "Send a custom email" set up that fires first. This second scriptrunner email isn't based off of any condition or configuration and just notifies different managers of the change in status.
However, if I simply edit that field without transitioning the issue, the email does fire.
Hi Jeff,
This happens because the listeners aren't triggered during the transition because there's no Issue Updated event fired for it.
As far as I could understand you have set up several listeners, one per team, and you validate the team name in the condition to know where to send the email, correct?
I would suggest the following changes:
That way you won't get the email in case there was a regular issue update without a transition, because the listeners will be triggered only by your custom events.
Let me know what you think and if any help is needed.
Tanya
Thanks Tanya! Actually, I didn't do quite what you said, but when you mentioned the reason is that no Issue Updated event was fired for it, that made me think I should change the type of event in the workflow that was fired. I just changed it from Generic Event to Issue Updated event and then the listeners would pick it up. That seemed to work.
I do realize that if those fields are changed at any time, without a transition, the email will fire, but I think that's ok for our purposes. I appreciate your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great!
If you need anymore assistance in the future, don't hesitate to ask :-)
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.