convertToSingleSelect behaviour


We use convertToSingleSelect in two ways:

1. With a static list of values set in the script of the REST endpoint that the converted field is linked to - useful when we need a hideable single select list.

2. With an endpoint that is connected to an external database - to get data that can be updated by users that are not Jira admins but have access to that external database.

In the first scenario this behaviour is working like this:

When you select an option from the list that option is no longer accessible if you want to change selected option. So with every option that you select, the list is becoming shorter and shorter. 

In the second scenario when you select an option you cannot change it at all because the list becomes empty. You need to reload whole form to see full list again.

Is it possible to configure such converted field to behave the same way as a normal single select list? So all values remain in the list no matter how many times a user changes his mind while reporting new ticket. 



1 answer

1 accepted

2 votes
Accepted answer


For your first scenario, this should be possible. Could you please send me an example of the code you're using currently? I might be able to see where you need to make changes. 

For the second, you might take a look at this example:

Or, there are several other select list conversion examples here:


Hi Jenna,

In the first scenario we use following behaviour to convert a text field to single select list:

def score = getFieldById("customfield_16403")

ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner/latest/custom/scores",
query: false,
formatResponse: "general",
css: "max-width: 500px; width: 500px",

And a simple custom endpoint:

import groovy.json.JsonOutput
import groovy.transform.BaseScript
import javax.servlet.http.HttpServletRequest

@BaseScript CustomEndpointDelegate delegate

class pozycja {
def value
def label

scores () { MultivaluedMap queryParams, String body,HttpServletRequest request ->

def lista = ['1','2','3','4','5']
def result = []
def map = [:]

lista.each {
result << new pozycja(value:it, label:it)

map.put('items', result)


As for the second scenario -  I have looked into your examples (without it I couldn't make it running in the first place;) ) but I haven't found anything to make it work exactly as a true single select list.




Here's a simple example of a REST endpoint that does something similar to what you're wanting (for your first question) :

import groovy.json.JsonBuilder
import groovy.transform.BaseScript


@BaseScript CustomEndpointDelegate delegate

doSomething() { MultivaluedMap queryParams ->

    def query = queryParams.getFirst("query") as String
    def fullList = [:]
    def originalList = ['A', 'B', 'C'] // test list, put your list here!    
def list = [] if(query){ def length = query.length() originalList.each{ if(it.substring(0, length) == query){ list.push(it) } } } else{list = originalList} fullList = [ items: list.collect { [ value: it, html : it, label: it, ] }, ] return Response.ok(new JsonBuilder(fullList).toString()).build() }

 And here's the behaviour that goes with it:

    ajaxOptions: [
        url : getBaseUrl() + "/rest/scriptrunner/latest/custom/doSomething", 
        query: true, // keep going back to the sever for each keystroke        
minQueryLength: 1, keyInputPeriod: 500, formatResponse: "general", ] ])

My example probably needs some more intensive error handling added, so if something causes it to break keep that in mind. Hopefully that will help you out with your first question!

As far as querying the database, I'm not sure what you mean by making it a true single select. Can you send what you're doing currently?


Like 1 person likes this

Wow, that is clever! Thanks a lot, Jenna! I will try to implement this approach also to our second scenario (with a database).

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Jan 15, 2019 in Statuspage

Introducing Statuspage Getting Started guides! First up: What is Statuspage?

Over the next several weeks we'll be sharing some of our Getting Started guides here in the community. Throughout this series of posts, we'd love to hear from customers and non-customers ab...

271 views 4 2
Join discussion

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