I have a SR custom listener that is fired when an issue in a particular project is created. The script changes some fields then tried to transition the issue from the Open status to the Assigned status using the Assigned transition. When trying this the script throws the error:
It seems that you have tried to perform a workflow operation (Assigned) that is not valid for the current state of this issue (EPROREQ-1139). However, the transition is valid as I can make that very transition manually. In addition if I change the firing criteria to add issue updated the modify a field in the issue, the transition works correctly.
This indicates to me that there is a problem with when the script is triggered and not the script itself. The relevant code is:
void PerformTransition(actionId, log, scriptName) {
String methodName = 'PerformTransition'
log.debug(scriptName + ":" + methodName + ": actionId: " + actionId + "; Status: " + issue.getStatusObject().getSimpleStatus().getName());
IssueService issueService = ComponentAccessor.getIssueService()
// Set the action parameters
IssueInputParameters issueInputParameters = new IssueInputParametersImpl([:])
issueInputParameters.setComment("${scriptName}: Changed status to Assigned.")
// Get the currently logged in users
ApplicationUser applicationUser = ComponentAccessor.getJiraAuthenticationContext().getUser()
User user = ApplicationUsers.toDirectoryUser(applicationUser);
// Test the transition and see if it generates errors
IssueService.TransitionValidationResult validationResult = issueService.validateTransition(user, issue.id, actionId, issueInputParameters)
def errorCollection = validationResult.errorCollection
if (!errorCollection.hasAnyErrors()) {
IssueService.IssueResult issueResult = issueService.transition(user, validationResult)
} else {
log.debug(scriptName + ":" + methodName + ": Got transition errors");
log.debug("Validation Errors: " + errorCollection)
}
String finalStatus = issue.getStatusObject().getSimpleStatus().getName()
log.debug(scriptName + ":" + methodName + ": finalStatus: " + finalStatus);
}
Here is the log output when fired in issue creation:
Entering ESM Assignment (1.0.0); Field Changed; Segment/Region Alignment
ESM Assignment:getCustomFieldValue: Field: Segment/Region Alignment
ESM Assignment:getCustomFieldValue: value: Manufacturing - Brian Long
ESM Assignment: xjxc250
ESM Assignment: New assignee login: xjxc250; New assignee name: Jennifer Cavucci
ESM Assignment:PerformTransition: actionId: 21; Status: Open
ESM Assignment:PerformTransition: Got transition errors
Validation Errors: Errors: {}Error Messages: [It seems that you have tried to perform a workflow operation (Assigned) that is not valid for the current state of this issue (EPROREQ-1139). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.]
Here is the log output when the script was fired when the issue was updated
ESM Assignment:getCustomFieldValue: Field: Segment/Region Alignment
ESM Assignment:getCustomFieldValue: value: Manufacturing - Brian Long
ESM Assignment: xjxc250
ESM Assignment: New assignee login: xjxc250; New assignee name: Jennifer Cavucci
ESM Assignment:PerformTransition: actionId: 21; Status: Open
ESM Assignment:PerformTransition: finalStatus: Open
Interestingly, I see that both logs show "ESM Assignment:PerformTransition: finalStatus: Open" which is logged after the completion of the "issueService.transition" call. Obviously, there is some processing after the script exits that causes the state transition to be stored in the DB.
Any help determining why the transition is not taking effect after the Issue Create event would be much appreciated.