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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

77 views 0 5
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