Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Issue cant transitioned because validation ist false (Script Runner)

dD
Contributor
October 15, 2021

Dear Community,

In my project I want to transition specific issues, when they get assigned and the assignee is member of a specific group. Therefore I use the following code.

The code stucks in the first validation part. The transitionValidationResult.isValid() is false and so the transition stops. Do have any idea why? Can I skip the validation and just go ahead?

// importings
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParametersImpl

// Basis definations
def groupManager = ComponentAccessor.getGroupManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.issueManager
def issue = issueManager.getIssueObject(event.issue.key)
IssueService issueService = ComponentAccessor.getIssueService()
def actionId = 3
def actionBackId = 2 // change this to the step that you want the issues to be transitioned to
def transitionValidationResult
def transitionResult
def customFieldManager = ComponentAccessor.getCustomFieldManager()
log.debug("The issue type is: " + issue.getIssueType().name)

// Defining Variables
String ISSUE_TYPE_ID = "10202"
def Assignee = issue.getAssignee()
String groupName = "Lehrkräfte"

// If-Condition
if (issue.getIssueTypeId() == ISSUE_TYPE_ID && groupManager.getUsersInGroup(groupName).contains(Assignee)) {
log.info("If condition works")

transitionValidationResult = issueService.validateTransition(currentUser, issue.id, actionId,new IssueInputParametersImpl())
log.info(currentUser)
log.info(issue.id)
log.info(actionId)
log.info(new IssueInputParametersImpl())

log.info(transitionValidationResult.isValid()) // this causes the error

if (transitionValidationResult.isValid()) {
transitionResult = issueService.transition(currentUser, transitionValidationResult)
log.info(transitionResult.isValid())
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")
}
}

 

1 answer

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 15, 2021

I don't think there is anything wrong with your code, I suspect the transition cannot be performed because the issue isn't in the starting status for the transition, the user doesn't have permission to transition it, there's a condition stopping it, a validator is saying no, etc

Suggest an answer

Log in or Sign up to answer