Hello!
Please tell me how to change the status for tasks correctly?
Given:
issueKey = "TEST-1"
currentStatus = "In Progress"
nextStatus = "Done"
So, the transition "InProgress -> Done" has an id = 900. Community documentation recommends using {{IssueService}}, which is what I am trying to do...
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.MutableIssue
final String ISSUE_KEY = "TEST-1"
int ACTION_ID = 900
def issueService = ComponentAccessor.getIssueService()
// context of the currentUser
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// getting issue via IssueService
MutableIssue issue = null
def getIssueResult = issueService.getIssue( user, ISSUE_KEY )
if( getIssueResult.isValid() == true && getIssueResult.getIssue() != null )
{
issue = getIssueResult.getIssue()
}
else
{
return "Issue not found!"
}
def params = issueService.newIssueInputParameters()
def transitionValidationResult = issueService.validateTransition( user, issue?.getId(), ACTION_ID, params )
if( transitionValidationResult.isValid() == true )
{
def issueResult = issueService.transition( user, transitionValidationResult )
if( issueResult.isValid() == true )
{
log.debug "valid. Issue is = ${issueResult.getIssue()}"
return issueResult.getIssue()
}
else
{
log?.warn "error"
return issueResult.getErrorCollection()?.getErrorMessages()
}
}
else
{
return transitionValidationResult.getErrorCollection()?.getErrorMessages()
}
"${transitionValidationResult.isValid()}"
and, my result is:
[It seems that you have tried to perform a workflow operation (Resolve) that is not valid for the current state of this issue (TEST-1). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.]
But, an issue TEST-1 haves the status "In Progress" and, this issue have the direct step/link to the "Resolved" status! Btw, i can change the status "In Progress" to "Resolved" manually, via IssueService - i got error.
So, how to transit an issues as correctly?