How to limit results returned in sellist

Hi everyone. I have created a new module that has tens of thousands of rows in it. When I create another module that has a select list to the object or a sellist, it is super slow because it is loading all 40,000 rows into the select list.

What is the best way of limiting this to show like 100 results when doing a search? I see that in Thirdparty, there is an option to turn off the select list and not search until 3 letters are entered. That would work for me, but it seems like that is a lot to implement.

Is there a better way to limit the number of results returned?

Nevermind. I figured it out. I will leave this here for other developers.

If you have a module with objects that have thousands of rows elements, you can easily change the Select2 drop down list into a Search box that does not get the elements until you start typing.

Simply get the name of your object. In my case it is “vehicle”, then add a constant under Setup → Other Setup, with the name of your object followed by… “_USE_SEARCH_TO_SELECT”

So in my case the constant I added was VEHICLE_USE_SEARCH_TO_SELECT.

Now the Select2 box will be changed to a search box instead and not load tens of thousands of select options on load. The value that you put into the constant will be the number of characters you have to type before the search will begin.

I am still checking to see how to create a limit on the number of total items returned on a search. I will post that information if I can find it.

Thanks

4 Likes

Thank you very much - that was exactly what I needed!

1 Like