How did you deal with new method com.atlassian.jira.issue.search.SearchResults.getResults()

After upgrade to Jira 8.X, the method getIssues() has been retired and instead with getResults().
But the return of getResults() is List.
I want to know how do you transform the return to List, or what method you use to instead of getIssues().
Thanks for you suggestions.

Hi @TedShi,

Welcome to the community!

What kind of transformation are you looking for here?

Cheers,
Anne

I don’t see any responses beyond the question posed back to the user here but I am also stuggling with transforming back into a valid Issue since SearResults only hands back a list of DocumentWithId… Any guidance is much appreciated

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.search.SearchQuery;

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def sdUser = ComponentAccessor.getUserManager().getUserByKey(‘xyz’)
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def query1 = jqlQueryParser.parseQuery(“project = APMTS”)
def searchQuery = SearchQuery.create(query1, sdUser);
def projectIssues = searchProvider.search(searchQuery, PagerFilter.getUnlimitedFilter())

log.warn(“All issues=” + projectIssues.total)
//if you want to do something with the issues, use the following loop

projectIssues.getResults().each() {
res ->
def doc = res.getDocument();
def key=doc.get(“key”)
def issue =issueManager.getIssueObject(key);
def ddiff= 0
if (issue.getResolutionDate() != null && issue.getDueDate() != null ) ddiff = Math.round((issue.getResolutionDate().getTime()-issue.getDueDate().getTime()) /3600/24/1000*10)/10
log.warn(issue.getKey()+","+ddiff+","+issue.getCreator()+","+issue.getDueDate()+","+issue.getResolutionDate());
}