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,365,124
Community Members
 
Community Events
168
Community Groups

How to use custom picker

hello community
I have a very tricky problem.
I want to use the custom picker field provided by ScriptRunner.
I hope this field, by calling the jira rest api interface, returns a certain type of issue, and finally the summary of these issues is used as a list for me to choose.
I saw an example provided by the documentation: country picker. But I don't know how to change it, the following is my code?

Remark: Regarding why I want to use rest api, because I use the normal issue picker field, I can't select the issue that I don't have permission to see, so I want to select the issue that I don't have permission to see through the current method

 
import com.onresolve.scriptrunner.canned.jira.fields.model.PickerOption

import groovyx.net.http.ContentType

import groovyx.net.http.HTTPBuilder

import groovyx.net.http.Method

HTTPBuilder getHttpBuilder() {

new HTTPBuilder("http://localhost")

}

search = { String inputValue ->

httpBuilder.request(Method.GET, ContentType.JSON) {

uri.path = inputValue ?

"/rest/api/2/issue/search?jql=reporter=${inputValue}" :

"/rest/api/2/issue/search?jql=reporter=admin"


uri.query = [fields:'key;summary']

response.failure = { null }

}

}

toOption = { Map<String, String> map, Closure<String> highlight ->

new PickerOption(

value: map.summary,

label: map.key,

html: highlight(map.key, false),

)

}

renderItemViewHtml = { Map country ->

"${country.key} (${country.summary})"

}

 

0 answers

Suggest an answer

Log in or Sign up to answer