Script Runner: Error when performing a search in the Script Console

Hello,

 

When I try to perform the following search in the Script Console, I get the following error from the Script Console:

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.user.ApplicationUsers;
import com.atlassian.jira.web.bean.PagerFilter;

User user = ApplicationUsers.toDirectoryUser(ComponentAccessor.getJiraAuthenticationContext().getUser())
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
List<Issue> issueBoardIssues = searchService.search(user, searchService.parseQuery(user, "project = IB"), PagerFilter.getUnlimitedFilter()).getIssues()

...
No signature of method: 
com.atlassian.jira.bc.issue.search.DefaultSearchService.search() is 
applicable for argument types: 
(com.atlassian.jira.user.BridgedDirectoryUser, 
com.atlassian.jira.bc.issue.search.SearchService$ParseResult, 
com.atlassian.jira.web.bean.PagerFilter) values: [admin:1, 
com.atlassian.jira.bc.issue.search.SearchService$ParseResult@25a3037, 
...]
Possible solutions: search(com.atlassian.crowd.embedded.api.User, 
com.atlassian.query.Query, com.atlassian.jira.web.bean.PagerFilter), 
each(groovy.lang.Closure)

 

JIRA 6.2

Script Runner 3.0.5

 

 

Best regards

Jens

2 answers

1 accepted

My fault ...

I forgot to call getQuery on SearchService.parseQuery:

...
List<Issue> issueBoardIssues = searchService.search(user, searchService.parseQuery(user, "project = IB").getQuery(), PagerFilter.getUnlimitedFilter()).getIssues()
...
As error says, the parameters dont match the search method.

I use something like this.

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.issue.search.SearchResults
import com.atlassian.jira.jql.builder.JqlClauseBuilder
import com.atlassian.jira.jql.builder.JqlQueryBuilder
import com.atlassian.jira.user.ApplicationUsers
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.query.Query

SearchProvider searchProvider = ComponentAccessor.getSearchProvider()
User user = ApplicationUsers.toDirectoryUser(ComponentAccessor.getJiraAuthenticationContext().getUser())
JqlClauseBuilder builder = JqlQueryBuilder.newClauseBuilder();

Query query = builder.status("Open").and().project().eq("ABC").buildQuery()
SearchResults searchResults = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter());

But the error message does not make sense, because: com.atlassian.jira.user.BridgedDirectoryUser implements com.atlassian.crowd.embedded.api.User

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...

164 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