I'm trying to transition Issue from a post function of transition from some status to itself.
I'm facing either:
If the code is placed first, the value of the custom field that is filled in the last screen is not available (needed for my logic, should transition only for specific value).
And if the code is placed after the first, the status is not really changed (in the Activity, Transitions and History it looks like the status is changed but in fact not changed).
What am I missing?
How should I transition Issues from a post function in Jira 9.x?
The code:
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUser
IssueService issueService = ComponentAccessor.getIssueService()
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Integer actionId = 31
if (someCustomField == "X"){
IssueService.TransitionValidationResult result = issueService.validateTransition(user, issue.getId(), actionId, issueService.newIssueInputParameters())
if (result.isValid()){
IssueService.IssueResult issueResult = issueService.transition(user, result)
}else{
log.error(result.getErrorCollection().getErrors())
}
}