is there a way to sort the options that we add to a list with g_form.addOption()?

sharmavikrant
Kilo Expert

is there a way to sort the options that we add to a list with g_form.addOption()?

16 REPLIES 16

Hi Vikrant,



        you have to define dat particular field and itz value to remove the option..so i hope oly that field and choice value will be removed.


Regards
Harish

How do I sort the options though even after removing it?


User140988
Kilo Guru

Hi Vikrant,



Not sure if you have tried this, but is it not possible to take all the values in an array, sort them first and then use addOption to add it in sequence.


I though about it but I am using a glide record and not sure how to get the value for the glide record in an array?


Hi Vikrant,



That shouldnt be a problem, you can declare an array, use the while loop of the glide record and store the values in array. Using a simple example below, replace with your respective field names and gr for gliderecord object.


var arr = [];


var i = 0;


while(gr.next()){


arr[i] = gr.value;


i++;


}



you can use arr.sort(); statement to sort in alphabetical order if this solves your problem.