Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Scriptrunner Listener Reindex - Static Check error, though reindex works

I have followed previous instructions on performing a reindex in my listener after copying values from a parent to a linked issue. The reindex works, but I am hoping to figure out and clear the static check error if possible.

 

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink

import com.atlassian.jira.issue.link.IssueLinkType
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.fields.IssueLinksSystemField
import com.atlassian.jira.event.type.EventDispatchOption

import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.project.version.Version

import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.util.ImportUtils

ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser

IssueIndexingService indexing = (IssueIndexingService) ComponentAccessor.getComponent(IssueIndexingService.class)

def reIndexIssue(issue){
//Re-index the issue after update
boolean wasIndexing = ImportUtils.isIndexIssues()
ImportUtils.setIndexIssues(true)
IssueIndexingService.reIndex(issue)
ImportUtils.setIndexIssues(wasIndexing) }

 

Screen Shot 2021-01-25 at 10.02.46 AM.png 

Even though this works and reindex happens, am I being to nit picky trying to clean up this error?

1 answer

1 accepted

0 votes
Answer accepted

Hi @Casey Hinkle I understand you, but you are using groovy language which allows you for example to not to define types of the variables, so the source code is simpler.

If you want to solve this static check error, you have to set "issue" as an instance of com.atlassian.jira.issue.Issue:

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink

import com.atlassian.jira.issue.link.IssueLinkType
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.fields.IssueLinksSystemField
import com.atlassian.jira.event.type.EventDispatchOption

import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.project.version.Version

import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.util.ImportUtils

ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser

IssueIndexingService indexing = (IssueIndexingService) ComponentAccessor.getComponent(IssueIndexingService.class)

def reIndexIssue(Issue issue){
//Re-index the issue after update
boolean wasIndexing = ImportUtils.isIndexIssues()
ImportUtils.setIndexIssues(true)
IssueIndexingService.reIndex(issue)
ImportUtils.setIndexIssues(wasIndexing) }

Thank you Martin!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Why you should move agile planning to Lucidspark’s digital whiteboard

During my 17 years as a coach, mentor, and trainer of Agile teams, I’ve participated in hundreds of Agile planning meetings. The end result was a wall of backlog items annotated by an explosion of co...

102 views 0 5
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you