Ordered list of options for LookupField

I am using setOptionMap() with LookupField to provide the list of options/values. However, I noticed on the screen, the dropdown doesn’t order the list of options. How do I order the dropdown list so it is easier for the user to search for any option ?

CK

Use the setOptionsList. The List collection can be sorted as you want.
Map is an unordered collection.

Thanks. But I needed a different Value and Display Text for each option in the Lookup. I have recently solved it by using a LinkedHashMap (instead of HashMap) and it seems to display the options according to the order I have inserted the options into the LinkedHashMap.

1 Like