What is the default "ORDERBY" for GlideRecord?

Vinay Krishna1
Kilo Guru

Hi all,

 

What is the default order the system queries/displays records in GlideRecord API? 

 

For example, 

var gr=new GlideRecord('incident');

gr.query();

while(gr.next())

gs.print(gr.number);

 

The system displays all incident numbers, but in what order? It's not based on "sys_created_on", so I wonder what it is.

 

Thank you. 

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi Vinay,

 

ServiceNow docs has answer to all our questions. Follow link for detailed explanation of sorting mechanism.

 

Thanks,

Jaspal Singh

View solution in original post

5 REPLIES 5

Siddhnath Pande
Mega Guru

Hey Vinay,

Whenever you glide any list or record, all lists have a default sort sequence based on the type of fields present in the list. it's quite difficult to explain as it depends on the type of field present.

But if you want sort in any order you can use "orderby"  query.

This above reply might not be the exact answer, what you ask for But it is Helpful or you find it is Correct please mark it.

 

Thanks and Regards:
Siddhnath Pandey

 

 

Jaspal Singh
Mega Patron
Mega Patron

Hi Vinay,

 

ServiceNow docs has answer to all our questions. Follow link for detailed explanation of sorting mechanism.

 

Thanks,

Jaspal Singh

Hi Jaspal,

 

Thank you for the link. It was very helpful. But let's take incident table for an example. It doesn't sort by either number or name or order field, neither does any of the fields have "isOrder" attribute. So it must be user preference, but where exactly can we define user preference?

Hi Vinay,

 

You can follow link & replace the instance_name in the URL with your instance. For every user there would be a preference & when script it executed it follows that.

 

Thanks,

Jaspal Singh