JIRA system reindexing skipping a custom field

Jihad Sabra September 23, 2024

Hi Team,

I have a simple calculated scripted number field (JMCF app field with default search template of "Number Range Searcher (Statistics-Compatible)" ) that calculates the number of issue links in certain projects that are associated with a particular target project. So if my field is called "XYZ Count" and is configured on A,B,C projects, then issues in A,B,C projects will have "XYZ Count" values that represent the count of all the links that are associated with the XYZ project (code below for clarity):

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.link.IssueLink

import com.atlassian.jira.issue.link.IssueLinkManager

def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def projectKey = "XYZ"

def linkedIssuesCount = 0

def linkedIssues = issueLinkManager.getLinkCollection(issue, ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()).allIssues

def projLinkedIssues = linkedIssues.findAll { linkedIssue -> linkedIssue.getProjectObject().getKey() == projectKey }

if (projLinkedIssues) {

     linkedIssuesCount =projLinkedIssues.size();

}

if (linkedIssuesCount > 0) {

      return linkedIssuesCount;

}

After our weekly weekend system reindexing, I see issues in A,B,C projects have proper values populated in the "XYZ Count" field, however they're not being properly indexed as JQL queries like ["XYZ Count" is not EMPTY] don't pick them up. If I manually reindex A,B,C projects then reindexing happens and my JQL queries work just fine. However, the next weekly system reindex will take me back to square one.

If anyone can shed any light as to why system reindexing doesn't pick that field, or if there is a better alternative to achieve such functionality, that would be greatly appreciated.

Thanks.

1 answer

0 votes
Jihad Sabra October 30, 2024

Just a quick update on this matter,

replacing the above code with the following seems to have fixed the issue

issue.linkedIssues.findAll{it -> it.get("project").key == "XYZ"}.size()?: null

 

Suggest an answer

Log in or Sign up to answer