Permanently sort a list from a to z

Cupcake
Mega Guru

I created a table that contains a list of roles.

When I created the table and added the values, I added them in alphabetical order but when you go to the form and click the magnifying glass the list is not sorted correctly.

How can I resolve this problem globally?

Can someone answer why is this happening, I've never had this issue reported before?

This is the table                                                                                                                                                                                   This is the Form in the portal

find_real_file.png                   find_real_file.png

Thanks,

Karen

8 REPLIES 8

Andrii
Kilo Guru

That happens because ServiceNow sorts not by Display value(labels that you types) but by real values of these fields. You may add ^ORDERBY to your module or URL where you call this list


shloke04
Kilo Patron

Hi,



You can write a Before Query Business Rule on your required Table and write the script as below:



Script:



  var query = 'ORDERBYDESCsys_created_on';       // Replace sys_created_on with your field Name on which you want to sort


  current.addEncodedQuery(query);



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

shloke04
Kilo Patron

Hi Karen,



If your query is Resolved, Please mark the answer as correct so that the thread can be removed from the Unanswered list.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

shloke04
Kilo Patron

Hi,



Did you got a chance to Test the Solution provided for your query.



If your query is Resolved, Please mark the answer as correct so that the thread can be removed from the Unanswered list.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke