Hi Atlassians,
Inside my postfunction, I'm using IssueService.IssueResult transition method in order to transition an issue through workflow.
As specified in the documentation, the issue will be saved and re-indexed and the transition will be made.(https://docs.atlassian.com/jira/6.2.1/com/atlassian/jira/bc/issue/IssueService.html#transition(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult) ).
As I understand from that, there is no need to update the issue by code as this method will do it.
In my code, I noticed that the transition is happening (by checking History tab) but the issue is not saved (Status is not modified). I used to put issueManager.updateIssue (kindly ckeck highlighted line in the below code) after it in order to force updating the issue.
My question is: Why implementing IssueService.IssueResult transition is not enough to save the issue after transitioning it?
My code is the following:
TransitionValidationResult transitionValidRes = issueService.validateTransition(authenticationContext.getUser().getDirectoryUser(),issue.getId(),configAction.getId(), issueInputParameters);
log.debug("Current Status of the issue: " + issue.getStatusObject().getName());
log.debug("Action ID: " + configAction.getId());
if (!transitionValidRes.isValid())
{
Iterator<String> ite = transitionValidRes.getErrorCollection().getErrorMessages().iterator();
StringBuilder sb = new StringBuilder();
while (ite.hasNext())
{
sb.append(ite.next());
sb.append("\n");
}
throw new Exception(sb.toString());
}
ErrorCollection transitionErrorCollection = issueService.transition(authenticationContext.getUser().getDirectoryUser(), transitionValidRes).getErrorCollection();
if (transitionErrorCollection.hasAnyErrors())
{
log.error(transitionErrorCollection.toString());
}
else
{
log.debug("New Status of Issue: " + transitionValidRes.getIssue().getStatusObject().getName());
}
issue.setStatusObject(transitionValidRes.getIssue().getStatusObject());
issueManager.updateIssue(authenticationContext.getUser().getDirectoryUser(), issue, EventDispatchOption.ISSUE_UPDATED, false);
Thanks,
Rosy