How can i order a choice list using the Sequence number Not the Value per OOB specs

Dan119
Mega Contributor

We have this issue: Customer wants the choice list value to have 'Other' always at the bottom of the drop down.

Case in point:

Subcategory: Fruits

Choices: Apple,Banana,Cantaloupe,Orange,Kiwi,Mango,Other

when you have a form and the drop down for the choice list, the order comes alphabetically. So Other, comes right after Orange. So I am looking for a script that would accomplish this. I have read numerous SNOW postings all saying that it always use alpha-numeric sorting.

Any help would be appreciated.  Oh just for information, I have already tried gs.orderBy('sequence'); in a script includes, and that still doesn't work.  Thanks

4 REPLIES 4

AbhishekGardade
Giga Sage

Hello Ramon,

Check out the below screenshot,

find_real_file.png

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

Thank you,
Abhishek Gardade

Alikutty A
Tera Sage

Hi,

I believe you are populating the choices using a script and this is the reason why your sequence order is not auto rendered. Why dont you use the choice list or select box types of fields? It will respoect your sequence OOB.

Again if you still need script,  gs.orderBy('sequence'); is not the correct syntax. You should be using

 gr.orderBy('sequence'); where gr is your GlideRecord on sys_choice table.

Dan119
Mega Contributor

Hello Ailkutty, the order by works in the Self Service side for both New Record and for when the ticket is created. We are using a widget calling a record producer for the user on the Portal Side.  This is where I have the problem, as Anhishek clipped a screen print, my issue is not there. 

Can you please paste your widget code here? Also did you try changing gs ? gs is GlideSystem class and cannot be used to invoke orderBy.