I need a single select custom field that contains the names of the project names in the Jira instance. There already exists a project picker but is not yet supported in the customer portal, thing that is a MUST for me.
What i have done so far:
- Created a Rest Endpoint that returns all the project names
@BaseScript CustomEndpointDelegate delegate
getProjects () { MultivaluedMap queryParams, String body,HttpServletRequest request ->
def projectList = ComponentAccessor.getProjectManager().getProjectObjects()
def projects = []
for(String prName : projectList.name){
projects.add(prName)
}
return Response.ok(JsonOutput.toJson(projects)).build()
}
//Works checking with Postman!
- Created a behaviour on the initializer
def test = getFieldByName("TEST")
test.convertToSingleSelect([
ajaxOptions: [
url : getBaseUrl() +"/rest/scriptrunner/latest/custom/getProjects",
type: "GET",
dataType: 'json',
query: false, // keep going back to the sever for each keystroke
minQueryLength: 5,
keyInputPeriod: 500,
data : [
label : "Pick a Task in project",
],
formatResponse: "general",
],
css: "max-width: 500px; width: 500px",
])
The problem is that when i go to the converted single select customfield i can not see the results. Any idea?