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.