How can I run a transition's validators before making the transition in code?

Dov Frankel May 21, 2019

I'm trying to conditionally trigger a transition on linked issues as a post function, which is close to working, except that when the linked issue's transition validator fails, the transition that triggered the post function then fails as well, which I don't want. I'd like to skip the linked issue transition in that case, requiring it to be manual. This is what my code looks like:

def transitionValidationResult = issueService.validateTransition(
new IssueInputParametersImpl()

if (!transitionValidationResult.isValid()) {
log.error("'${actionName}' transition is not valid for ${linkedTicket.key}: ${transitionValidationResult.errorCollection}")
} else {"Transitioning...")

def transitionResult = issueService.transition(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), transitionValidationResult)

if (!transitionResult.isValid()) {
log.error("Failed to transition ${releaseTicket.key}: ${transitionResult.errorCollection}")

It seems like the validateTransition() call should return an invalid result, but then the actual transition fails. Am I missing something? Once the actual transition fails, it then automatically rolls back the original transition the user initiated. 

UPDATE It's been a few weeks since I asked this - does anyone out there have any ideas?

1 answer

0 votes
ITDev November 25, 2021

Seems like a bug in issueService. :-(

I have excactly the same problem. Here is the sample for test from Console:

import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor as CA
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Level
import org.apache.log4j.Logger

def ACTION_ID = 131
Issue issue = CA.getIssueManager().getIssueObject("B2-3082")
ApplicationUser user = CA.jiraAuthenticationContext.loggedInUser

IssueInputParameters issueParams = CA.issueService.newIssueInputParameters()
IssueService.TransitionValidationResult validationResult = CA.issueService.validateTransition(user,, ACTION_ID, issueParams) "validationResult: ${validationResult.isValid()} errors: ${validationResult.errorCollection.errors}"

if (validationResult.isValid()) {
def transitionResult = CA.issueService.transition(user, validationResult)
if (!transitionResult.isValid()) {
log.warn "Failed to transition issue ${issue.key}, errors: ${transitionResult.errorCollection.getErrorMessages()}"
} else { "Sussessful transition issue ${issue.key}"
} else {
log.warn 'Errors on validation:'
log.warn validationResult.errorCollection.errors
log.warn validationResult.warningCollection.warnings

2021-11-25 10:32:55,554 INFO [runner.ScriptBindingsManager]: validationResult: true errors: [:] 2021-11-25 10:32:55,672 WARN [runner.ScriptBindingsManager]: Failed to transition issue B2-3082, errors: [Comment: Please provide a comment for this transition]

Have you resolved this issue?

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events