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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to avoid the loading of options on a customfield list ?

Hello,

To give you the context, I have a first custom field with around 500 values that works well and second multiselect list with around 10000 values. 

The displayed options of the second list depend of the value set on the first list (I used a json file to do this). 

// Récupérer les applications :
File file = new File("path.of.my.file")
def fileText = file.getText()
def list = new JsonSlurper().parseText(fileText)

def result = list['Projets'].find {
it['LibelleProjet'] == tabG2 }['Activites'].collect { it['CodeActivite'] + '_' + it['libelleActivite'] }

def optionsMap = options.findAll {
it.value in result // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap)

 So that works too.

The problem is that the 10000 values are always loaded in background and it causes slowness...

Is it possible to avoid that forms load the 10000 values ?

I tried to do that on an intialiser but it's always slow, the options are always loaded in backgound

def result

def optionsMap = options.findAll {
it.value in result // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap)

If you have suggestions for an alternative, do not hesitate to answer :) 

1 answer

0 votes

Hi

Wow, 500/1000 values in a select!

That must be a pain to manage.

Considering that behaviour only impacts the DOM in the browser via javascript, the setFieldObptions can only hide the elements you don't want to show. There is no way to prevent jira to load those values.

I think you might have better performance given your use case if you use 2 plain text fields and convert them using the behaviour convertToSingleSelect method.

This would require you to create a rest endpoint to serve data from your JSON.
But the advantage here is that you only serve the result that matches the user's type-ahead query and the value selected in the first field.

The other advantage is that now you only have a single place to manage the list of values. I am guessing that right now, to add a new value, you must add it both to the custom field configuration and in the JSON file.

Also, you can start to consider putting the data elsewhere than in a JSON file. Perhaps another database you might have access to.

Thanks for you reply!

Unfortunately this is the solution we are currently using but it is causing us problems that we are no able to solve.

With the same mecanism, the option displayed on the second list depent of the value on the first one and when we try to set values on the second, we have an error ...

Capture.PNG

After long investigations we didn't find what was the problem and it's why we tried the second option to directly load the value on "classic" fields.

For information, I use my json to add value in my two fields with the help of a script. 

So with this solution, I also have a single place to manage my lists. 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

682 views 7 23
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you