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:
@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!
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?
The problem was that in the rest Endpoint i was sending a simple list, that could not be read from the Javascript on the behaviour. So in the Rest endpoint i added this code :
fullList = [
items: projects.collect {
[
value: it,
html : it,
label: it,
]
},
]
return Response.ok(new JsonBuilder(fullList).toString()).build()
And it Worked!!!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.