Reindex after transition by scriptrunner Edited

Hi everyone,

I got a problem similar to the one described here, with difference that there was described an update issue problem, and now it is a transition issue problem. 

So in general it looks like this:

I do auto transition in script post function by scriptrunner and mostly it is fine except some issues that are not being reindexed properly. So issue is actually in the right status, but before I update it in any other way it appears in the old status in search. 

Here is my code:

Integer actionId = actionI.intValue()

if (!issueInputParameters) {
issueInputParameters = ComponentAccessor.issueService.newIssueInputParameters();
}

IssueService.TransitionValidationResult transitionValidationResult = ComponentAccessor.issueService.validateTransition(applicationUser, issue.id, actionId, issueInputParameters)

log.debug logPref + "Transitioning issue: " + issue.id + " transitionValidationResult " + transitionValidationResult

if (transitionValidationResult.isValid()) {
IssueService.IssueResult transitionResult = ComponentAccessor.issueService.transition(applicationUser, transitionValidationResult)
if (transitionResult.isValid()) {
log.debug 'Issue transitioned. Action Id: ' + actionId
ReindexIssue(issue, logPref)
} else {
log.error 'Error executing transition with action Id ' + actionId
}
} else {
log.error logPref + "Validation error: " + transitionValidationResult.getErrorCollection()
List<String> errorList = new ArrayList();
errorList.addAll(transitionValidationResult.getErrorCollection().getErrorMessages());
for (int i = 0; errorList != null && i < errorList.size(); i++) {
log.error 'Error validating transition with action Id ' + actionId + ' :' + errorList.get(i);
}
}

static void ReindexIssue(Issue anIssue, String logPref) {
boolean wasIndexing = ImportUtils.isIndexIssues()
ImportUtils.setIndexIssues(true)
ComponentAccessor.getIssueIndexManager().reIndex(anIssue)
ImportUtils.setIndexIssues(wasIndexing);
}

Post Function is located right after storing to DB before reindexing. 

JIRA version is 6.4.7 and Scriptrunner is 3.1.3

Any help would be appreciated. 

2 answers

Hi Viktor 

Did you try to move the post function in the beggining ?

regards, Thanos

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

166 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you