I have placed the following code in the Create post-function after the "Issue Created" event is fired:
def IssueService issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def actionId = 11
IssueService.TransitionValidationResult transitionValidationResult = issueService.validateTransition(
user,issue.id, actionId,new IssueInputParametersImpl([:])
)
if(! transitionValidationResult.errorCollection.hasAnyErrors())
{
issueService.transition(user,transitionValidationResult)
}
However, the validateTransiton call returns the following error.
Errors: {}
Error Messages: [It seems that you have tried to perform a workflow operation (Planned) that is not valid for the current state of this issue (TASKTEST-28). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.]Note, that all of the conditions and validators are satisfied after the issue is created.
Whereas, the above code works fine if I place it somewhere else like in a IssueUpdated event listener
Thanks.