Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JQL search shows no results when label is added by script

Lander Albrecht May 26, 2020

I have a listener that adds a label when the version of a ticket is changed. This works without any problems but when i want to search issues that have the label, i get no results.

Do i need another step after the label has been added to update the ticket somehow? When reindexing the project, I get the results i want but i shouldn't reindex the whole project each time a fixversion is updated.

 

if (lastVersion != newVersion) {
def labels = labelManager.getLabels(issue.id).collect{it.getLabel()}
labels += 'Updated'
labelManager.setLabels(user,issue.id,labels.toSet(),false,false)
}

2 answers

0 votes
Payne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 26, 2020

I once wrote a post function that required re-indexing a just-modified issue, and here's the code that I used. You may try adding this after your setLabels() call.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.index.IssueIndexingService

def indexManager = ComponentAccessor.getComponent(IssueIndexingService.class)
indexManager.reIndex(issue)
0 votes
John Funk
Community Champion
May 26, 2020

Hi Lander,

It indeed sounds like you will need to re-index.  :-(

Lander Albrecht May 26, 2020

Right now I'm testing with the addLabel() method and I see good results. I'll come back on that tomorrow.

Suggest an answer

Log in or Sign up to answer