Sorting List Collector variable values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 08:15 AM
Hello,
We have a software list collector that contains 'Other'. The list currently sort by alphabetical order. Is it possible to move the 'Other' value to the bottom of the list? Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 09:42 AM
Sorry yours is a list collector, this is for drop downs.
I'll keep thinking and post back if I find something similar for list collector
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 09:51 AM
Thank you so much @Anurag Tripathi for your time and effort.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 10:18 AM
Hi @Erica2 ,
Hope you are doing great.
Try using below script n pn load client script:
function onLoad() {
// Check if the form is in the correct view and table
if (g_form.getTableName() == 'your_table_name') {
var listCollector = g_form.getControl('your_list_collector_field');
if (listCollector) {
// Get the options from the list collector
var options = listCollector.options;
// Custom sort function to move 'Other' to the bottom
Array.prototype.sort.call(options, function(a, b) {
if (a.text == 'Other') return 1;
if (b.text == 'Other') return -1;
return a.text.localeCompare(b.text);
});
// Refresh the list collector to apply the new sort order
g_form.refresh();
}
}
}
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 01:55 PM