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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,555,285
Community Members
 
Community Events
184
Community Groups

User context in which JQL query for issue picker custom field runs

Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Feb 27, 2021

Is there a way to run the query in a way so that permission checks are bypassed and all issues matching the JQL query are returned?

2 answers

1 accepted

1 vote
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 28, 2021

I don't think that's possible using the built-in issue picker.

But you might be able to achieve a similar purpose by using a plain text field and a conversion to a select list

This would require you to build a custom rest endpoint that mimics the built-in /rest/scriptrunner-jira/latest/issue/picker but ignores the current user permissions.

Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 03, 2021

Is there a chance to get the source of this built-in rest endpoint?

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 03, 2021 • edited

I don't have access to it, but it should be fairly simple to recreate the input and response.

Here I took a small stab at it:

import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response

@BaseScript CustomEndpointDelegate delegate

issuePickerNoSecurity(httpMethod: "GET", groups: ['jira-users']) { MultivaluedMap queryParams, String body ->
   def query = queryParams.getFirst('query')
   def currentJql = queryParams.getFirst('currentJql')
   def max = queryParams.getFirst('max') ?: 10

   def adminUser = ComponentAccessor.userManager.getUserByName('admin')

   def searchService = ComponentAccessor.getComponent(SearchService)
   def jql =''
   if(query.trim() && currentJql.trim()){
      jql = /$currentJql and text ~ "$query"/
   } else if (currentJql.trim()){
jql = currentJql
} else if(query.trim()){
jql=/text ~ "$query"/
}
def jqlParseResult = searchService.parseQuery(adminUser, jql)
def pager = new PagerFilter(max as Integer)
def results = searchService.searchOverrideSecurity(adminUser, jqlParseResult.query, pager)
def output = [sections:[
[label: 'Select Issue',
sub : "Showing $max of $results.total matching issues",
jql: jql, id:'cs',issues:
results.results.collect{
def issue = ComponentAccessor.issueManager.getIssueObject(it.key)
[key: issue.key, keyHtml: issue.key, img:issue.issueType.iconUrlHtml,
summary: issue.summary.replaceAll(/(?i)($query)/, '<b>$1</b>'),
summaryText: issue.summary,
id:issue.id]
},
totalIssues: results.total
]]]
return Response.ok(new JsonBuilder(output).toString()).build();
}

This doesn't use the other options like showSubTasks.

Also, note that with this, you don't get a preferential list of issues based on the current users' recently viewed issues.

Like Dieter likes this
Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 03, 2021 • edited

Thank‘s a lot for this 👍

Very helpful!

0 votes
Benz Kek _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Feb 28, 2021 • edited

Hi Dieter, I don't think that is possible because Jira API for SearchService.search() takes in an ApplicationUser parameter no matter what.

The only way to work around this is to use a superuser instead to do the search. 

In any case, using JQL searches in Scripted Field is not recommended as mentioned here: JQL Searches in Script Fields

Otherwise, you will get issues with full reindexing. If you still want to use it, do remember to check the index availability as suggested in the documentation. 

UPDATE: I just noticed you were referring to Issue Picker query, not search query in Scripted Field. In that case, Peter-Dave Sheehan's reply is more relevant. Can't believe we commented at the same time though, Peter. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events