Does orderby query work for sys_created_on field?

upasanamahanta
Mega Contributor

Does orderby query work for sys_created_on field?

3 REPLIES 3

Anurag Tripathi
Mega Patron
Mega Patron

yes, it does.



I am not sure what issue are you facing, but you can also order on the number field also as it will always be in incremental order only.


-Anurag

ghsrikanth
Tera Guru

Yes, please write the code -


gr.orderBy('sys_created_on');



GlideRecord - ServiceNow Wiki



Mark if it is helpful or correct, feedback is appreciated


Mihir Mohanta
Kilo Sage

Hi Upasana,



Yes orderBy() works on sys_created_on field.



If you want to sort the records in ascending order then use below script in the glide record query:


gr.orderBy("sys_created_on");


If you want to sort the records in descending order then use below script in the glide record query:


gr.orderByDesc("sys_created_on");



Thanks,


Mihir