I have 3 different issue types in this scenario - S, P, and CI. CI is a sub-task. CI's are sub-tasks of Ps. P's and S's get linked together. With Script Runner, I have a custom event listener (AbstractIssueEventListener) that listens for IssueGenericEvent. The script checks to see if the event is for a CI. The P issue type gets its status calculated based on all of its CIs. S issue types get their status calculated based on all linked P statuses.
The listener sees that a CI has a status change, re-calculates the new status for the parent P, and then re-calculates the new status for any S linked to the parent P. Everything is working, except only the P seems to not get re-indexed properly. It doesn't "filter" correctly based on the status, but it shows the correct status in the UI. If I comment on the P then it behaves correctly.
Here's the code I'm using to transition both the P and the S's:
private void transitionIssue(Issue issue, int transitionID, IssueInputParameters issueInputParams){ TransitionValidationResult validationResult = issueService.validateTransition(user, issue.id, transitionID, issueInputParams) if(validationResult.isValid()){ IssueResult transitionIssue = issueService.transition(user, validationResult) if(!transitionIssue.isValid()) log.error("Transition issue wasn't valid!") } else log.error("Failed to transition " + issue.getKey() + ", bad validation: " + validationResult) }
I don't receive any log messages from performing the transition. The P is always transitioned first if that could make a difference.
I understand that IssueService.transition is supposed to perform a reindex. This is working for the S's but not the P. I've also tried suggestions from other posts such as doing a reindex in a separate thread, using the IssueIndexManager.reindex, and using IssueService.update. None of these have gotten the P to reindex.
Versions: Script Runner 4.1.3.4. JIRA 6.4.6.
Thank you in advance for any suggestions.
Community moderators have prevented the ability to post new answers.
Hi, as I had to write another script that does something similar as yours (transition an issue in a listener script), some more observations: the IssueService.transition method does certainly no re-index. Without the issueIndexManager.reIndex(issue) command just after IssueService.transition command, the new status of my issue was not considered in searches, as in your case. I added the reIndex command (in the same thread), and everything worked fine.
The API says "The issue will be saved and re-indexed" so IssueService.transition is supposed to do a reindex. I've already tried to add IssueIndexManager.reIndex(Issue) but this didn't fix my issue. Thank you for the suggestion.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, hmmm, no, I added this re-index at the same place and never got any problems with indexes out of sync anymore...
Maybe also have a look at https://answers.atlassian.com/questions/188231 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I took a look at the link (I actually came across that post before I asked my question) - that user's situation seems slightly different than mine - his status didn't appear correctly on some screens while mine appears correct on all screens but isn't filtered on correctly. I tried to perform a separate thread reindex again and it didn't change anything.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I had similar issues, and added next code after a save or transition:
IssueIndexManager issueIndexManager = ComponentAccessor.getIssueIndexManager(); issueIndexManager.reIndex(issue);
It solved all my cases...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What do you mean after a save or transition? I tried to use IssueIndexManager.reIndex(Issue issue) in my event listener after I performed the transition. This didn't solve my problem. Are you suggesting to do this somewhere else?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.