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")
}
}
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.