While trying to transition an issue with a listener on Issue Created event getting error:
Errors: {} Error Messages: [It seems that you have tried to perform a workflow operation (gateway - to do --> to verify) that is not valid for the current state of this issue (QA-109070). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.]
Works perfectly fine on the same transition after issue is created. User has enough permissions to do it manually as well. Here's the code:
void execTransition(ApplicationUser currentUser, Issue issue, int transId){
def issueService = ComponentAccessor.getIssueService()
IssueInputParameters issueInputParameters = new IssueInputParametersImpl()
issueInputParameters.setSkipScreenCheck(true)
TransitionOptions transitionOptions = new TransitionOptions.Builder().skipConditions().skipPermissions().skipValidators().build()
def transitionValidationResult = issueService.validateTransition(currentUser, issue.id, transId, issueInputParameters, transitionOptions)
if (transitionValidationResult.isValid()) {
IssueService.IssueResult trans = issueService.transition(currentUser, transitionValidationResult)
if(!trans.isValid()){
log.warn "Transition invalid"
trans.errorCollection.each {err ->
err.getErrorMessages().each {err1 ->
log.error err1.getProperties()
}
}
}
} else {
log.warn "Validation invalid"
transitionValidationResult.errorCollection.each {err ->
log.error err
}
}
}
I saw Jamie's comment here but I still need to do it in listener
Hi @Viktor Kuzmychov the problem with listener is that issue is not created yet when this listener is executed. If you really need to do it in listener, you can try to execute the code with separate Thread with some Thread.sleep on the beginning of the code block but it is not nice... politely speaking :)
@Martin Bayer [MoroSystems, s.r.o.]
Thank you so much! you saved my day.
Also I don't get it. Create transition has Post Functions:
Create issue
Reindex issue
Fire event
I thought it is created by the time of event fired.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had real problems transitioning issues programmatically. In one of my workflows it worked very well. In another it would always leave the issue in a semi-transitioned state. I wonder if somehow the task had not been fully updated or something in the database although I was doing it at the end of my post functions list.
I ended up using the Fast-Track post function and using a condition blob to set it up. You can use any code and return true or false at the end to cause the transition. If I needed additional functions called I would call it in code after the fast-track was done.
Hope this helps.
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.