Getting this error below while running the below code ,
Transition Validation errors: It seems that you have tried to perform a workflow operation (Done) that is not valid for the current state of this issue (ILAB-1251). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.workflow.TransitionOptions
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue
import org.apache.commons.lang3.StringUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory;
Logger log = LoggerFactory.getLogger("Subtask transition script")
//def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("RFA-467")
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager();
Collection<Issue> subTasks = issue.getSubTaskObjects()
log.error("Found {} subtasks of <{}> issue, starting transitions", subTasks.size(), issue.getKey())
if (subTaskManager.subTasksEnabled && !subTasks.empty)
{
IssueService issueService = ComponentAccessor.getIssueService()
CommentManager commentManager = ComponentAccessor.getCommentManager()
String comment = "Moving to *new status* status as a result of the *this transition* action being applied to the parent.";
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()
TransitionOptions transitionOptions = new TransitionOptions.Builder().skipConditions().skipPermissions().skipValidators().build()
subTasks.each {it ->
log.error("Try to transition subtask <{}>", it.getKey())
// In validateTransition method you should write transtion id, in this example 21
IssueService.TransitionValidationResult transitionValidationResult = issueService.validateTransition(user, it.getId(), 71, issueInputParameters, transitionOptions)
if (transitionValidationResult.isValid()){
IssueService.IssueResult issueResult = issueService.transition(user, transitionValidationResult)
if (!issueResult.isValid()){
String cause = StringUtils.join(issueResult.getErrorCollection().getErrorMessages(), "/")
log.error("Transition errors: {}", cause)
}
else{
log.error("transition issue <{}>, finished with result <{}>, adding comment", it.getKey(), issueResult.isValid())
commentManager.create(it, user, comment, true);
}
}
else{
String cause = StringUtils.join(transitionValidationResult.getErrorCollection().getErrorMessages(), "/")
log.error("Transition Validation errors: {}", cause)
}
}
}