How to sort advanced reference qualifier for a reference field?

Bharati Paidiap
Tera Contributor

I am using a script include for reference qualifier, but now the list should be sorted . Is there any way this can be achieved?

19 REPLIES 19

chetan1742
Kilo Contributor

Can you provide your script include code?

Voona Rohila
Kilo Patron
Kilo Patron

Hi 

You can use orderByDesc/orderBy to sort the

gr.orderByDesc('field_name'); //descending order

gr.orderBy('field_name'); //ascending order

 

Example:

var gr = new GlideRecord('incident');

gr.orderBy('number');     

gr.orderBy('sys_created_on');//ascending order by created date.

gr.query();

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Bharati Paidiap
Tera Contributor

Am not really glide recording anything rather just returning an encoded query.

 

return 'u_category=' + current.u_case_number.u_dispatch.u_category + '^u_field_name=u_billableratecardcategory' + '^u_mapping_type=Value' + '^u_active=true'+'^ORDERBYu_label';

Looks like orderby is already added, Is it not working?

 

return 'u_category=' + current.u_case_number.u_dispatch.u_category + '^u_field_name=u_billableratecardcategory' + '^u_mapping_type=Value' + '^u_active=true^ORDERBYu_label';


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP