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.
It seems that user who do this transition is not allowed to do it. Check that this user has respective permission
I do have access since I can make the transition manually. Second, it works correctly when the event is update but not if it is create.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
More one option: any updates should be done after store an issue to a database. See postfunction list.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use com.atlassian.jira.bc.issue.IssueService#validateTransition(com.atlassian.jira.user.ApplicationUser, java.lang.Long, int, com.atlassian.jira.issue.IssueInputParameters, com.atlassian.jira.workflow.TransitionOptions), TransitionOptions has flags to skip permissions and conditions etc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should use the Fast-track transition script... there are a load of corner cases and this scripts handles them.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.