How to sort created on fields using query?

upasanamahanta
Mega Contributor

How to sort created on fields using query?

2 REPLIES 2

ghsrikanth
Tera Guru

You can order by created on in glide query by the below function -


gr.orderBy('sys_created_on');



GlideRecord - ServiceNow Wiki



Mark if it is helpful or correct, feedback is appreciated


Mihir Mohanta
Kilo Sage

Hi Upasana,



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