What is the difference between addOrderBy and OrderBy glide record method.

Veronica11
Tera Contributor

What is the difference between addOrderBy and OrderBy glide record method.

1 ACCEPTED SOLUTION

Sujata Vishwak1
Mega Expert

Hi Jyoti,

addOrderBy(String column)

Adds a column to order by in the query.

Eg:

var gr = new GlideRecord('incident');

gr.addOrderBy('number');      -->Here, number column of incident will be placed in order.

gr.query();

 

orderBy(String column)

Specifies an orderBy column.

Eg:

var gr = new GlideRecord('incident');

gr.orderBy('number');     

gr.orderBy('sys_created_on');       -->Here, you can add multiple columns

gr.query();

 

 

Difference : "OrderBy" May be called more than once to order by multiple columns.

 

 

 

Thanks,

Sujata Vishwakarma

 

 

Please mark if this is helpful.

View solution in original post

4 REPLIES 4

bardakov
Tera Expert

addOrderBy - Adds a column to order by in the query.

orderBy - Specifies an orderBy column and may be called more than once to order by multiple columns.

Veronica11
Tera Contributor

Viktor,

 

Could you please elaborate this with the help of example.

Sujata Vishwak1
Mega Expert

Hi Jyoti,

addOrderBy(String column)

Adds a column to order by in the query.

Eg:

var gr = new GlideRecord('incident');

gr.addOrderBy('number');      -->Here, number column of incident will be placed in order.

gr.query();

 

orderBy(String column)

Specifies an orderBy column.

Eg:

var gr = new GlideRecord('incident');

gr.orderBy('number');     

gr.orderBy('sys_created_on');       -->Here, you can add multiple columns

gr.query();

 

 

Difference : "OrderBy" May be called more than once to order by multiple columns.

 

 

 

Thanks,

Sujata Vishwakarma

 

 

Please mark if this is helpful.

Thanks Sujata