1st Post!
So I've written a listener that I've got working on update events, but refuses to fire when on the initial issue creation.
The listener is intended to pick up on issues that don't have certain values set or are missing information and stick them into a Triage status. Once the tickets are in a good state after editing, the tickets go back to an open state.
I'd like to be able to expand on this listener over time to include more auto-transition scenarios, but need to be sure it works first in this simple Triage case.
My suspicion is the workflow isn't firing the event for whatever reason.
Hope the community can help me solve this, thanks!
Setup
In Listeners Section:
- Events Enabled: Issue Created, Issue Updated
Workflows:
On Create => Open, Fire a Issue Created event that can be processed by the listeners.
Script (works when editing):
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.issueManager
def issue = issueManager.getIssueObject(event.issue.key)
IssueService issueService = ComponentAccessor.getIssueService()
def actionId = 221 // change this to the step that you want the issues to be transitioned to
def actionId2 = 251 // change this to the step that you want the issues to be transitioned to
def transitionValidationResult
def transitionResult
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def resultfield = customFieldManager.getCustomFieldObjectByName("Result")
def resultfieldvalue = issue.getCustomFieldValue(resultfield).toString()
log.debug("The issue type is: " + issue.getIssueType().name)
if (issue.priority?.name != 'Not Set' && issue.status?.name == 'Triage') { // Looks for all issues that are ready to go out of triage
transitionValidationResult = issueService.validateTransition(currentUser, issue.id, actionId2,new IssueInputParametersImpl())
if (transitionValidationResult.isValid()) {
transitionResult = issueService.transition(currentUser, transitionValidationResult)
if (transitionResult.isValid())
{ log.debug("Transitioned issue $issue through action $actionId") }
else
{ log.debug("Transition result is not valid") }
}
else {
log.debug("The transitionValidation is not valid")
}
}
if (issue.getIssueType().name == "Bug" && issue.priority?.name == 'Not Set' && resultfieldvalue != null) { // looks for all bugs that need to go into triage
transitionValidationResult = issueService.validateTransition(currentUser, issue.id, actionId,new IssueInputParametersImpl())
if (transitionValidationResult.isValid()) {
transitionResult = issueService.transition(currentUser, transitionValidationResult)
if (transitionResult.isValid())
{ log.debug("Transitioned issue $issue through action $actionId") }
else
{ log.debug("Transition result is not valid") }
}
else {
log.debug("The transitionValidation is not valid")
}
}
I found a potential solution:
I'm just not sure how to add it to my script.
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.