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

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

Jens Goetz Nov 06, 2015

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

0 votes
Answer accepted
Jens Goetz Nov 10, 2015

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()
...
1 vote
Vijay Khacharia Nov 06, 2015
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());
Jens Goetz Nov 08, 2015

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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Webinar invitation: Generate custom Jira Cloud PDF reports and exports

Jira may be a staple part of your workday, but your colleagues, customers, business partners or an auditor might need information presented in a different format, that is easy to access and read. And...

61 views 0 1
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