I'm trying to change the status of an issue programmatically in a post function.
It seems like I am able to change the status of the issue but when I view the status of the issue on the issue page, it still shows the previous issue. In the activity log, it shows that the issue was changed.
This is a problem that I have seen in a few posts but a solution was never given in those threads.
I made sure that my post function runs before the indexing and I also tried indexing the issue in the code itself.
This is the code I have that does the transition.
Only when I get the post function to execute a second time, does the issue show the correct status in the UI.
this.validationResult = service.validateTransition(user, issue.getId(), actionId, issueInputParameters);
if(this.validationResult.isValid()) {
service.transition(user, validationResult);
reindexIssue(issue);
}
This breaks your Jira system because you are amending things that are in a state of flux.
A post-function is part of a transition. If you try to transition the issue again from within that, Jira gets very confused because you've changed your mind about the end state halfway through, and what you're trying to do might have a different starting point, so it has no choice but to write rubbish, and corrupt your issues.
Do not try to transition the current issue inside another transition.
Instead, use the SR fast-track transition to trigger a transition after the current one is complete, or write a listener to pick up the case where you want to transtion again.
Is there an example you can give SR fast track? Do I still use the validationResult code I have?
I did the same thing in a onIssueEvent function but the same thing happens. Activity log shows the issue status was updated but it is not reflected in the issue screen.
Edit: I'm not sure if I'll be able to use script runner in my workplace. Is using a listener the only way?
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.