I want to change the state of an issue as soon as it is created (based on a certain condition). I have used the following code to change the state of the issue:
JiraWorkflow workflow = ComponentAccessor.getWorkflowManager().getWorkflow(issue);
StepDescriptor stepDescriptor = workflow.getLinkedStep(issue.getStatusObject());
ActionDescriptor clarificationDescriptor=null;
for(int i=0;i<stepDescriptor.getActions().size();i++){
ActionDescriptor actionDescriptor = (ActionDescriptor) stepDescriptor.getActions().get(i);
String actionName = actionDescriptor.getName();
if(actionName.equalsIgnoreCase("Request Clarification")){
clarificationDescriptor = actionDescriptor;
}
}
if(clarificationDescriptor !=null){
User assigneeUser = issue.getAssigneeUser();
IssueService issueService = ComponentAccessor.getIssueService();
IssueInputParameters parameters = issueService.newIssueInputParameters();
parameters.setRetainExistingValuesWhenParameterNotProvided(true);
IssueService.TransitionValidationResult validationResult = issueService.validateTransition(assigneeUser, issue.getId(), clarificationDescriptor.getId(), parameters);
if (validationResult.isValid()){
// Do Something
}
else{
System.out.println(validationResult.getErrorCollection().getErrorMessages());
}
But this gives me the following error:
It seems that you have tried to perform a workflow operation (Received Clarification) that is not valid for the current state of this issue (INBOX-50). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.
I have cross verified that my workflow is correct. Also when I am trying to change the state through curl, I am able to do it. So what is the problem with the above code.