Reference qualifier with descending order

rajeevsaraf
Tera Contributor

Hi All,

 

I am trying to display incident number (reference field) in descending order on catalog item portal view.

I found, it can't be done using variable attribute as there is no parameter to set the order is descending. ref_ac_order_by only order result by user preference.

 

I tried even with script include , the result on BG is working fine and present incident number on descending order but same result on portal has ascending order.

 

 

getIncidentRecord: function(caller)
{
var inc = '';
var gr_incident = new GlideRecord('incident');
gr_incident.addEncodedQuery('caller_id='+caller);
gr_incident.orderByDesc('number');
gr_incident.query();


while(gr_incident.next()) {
inc += (',' + gr_incident.sys_id);

}
return 'sys_idIN' + inc;
}

 

I don't want to use BR for this purpose as ServiceNow will flooded with so many BR if such requirement comes on future for any other attribute. 

 

Can someone help me here, this seems very common requirement.

 

Many thanks in advance,

 

Regards,

Rajeev

3 REPLIES 3

Trevor Muhl
Kilo Sage

Hello, @rajeevsaraf. Do you see the following option in your instance? This is on version San Diego.

 

Variable Form.png

 

It seems that one can define the order and the direction of a variable's reference list here. However, I cannot get it to work properly, so there may be an issue present in my instance. Perhaps it will work for you?

Jagadish Sanadi
Kilo Sage

Hello,

 

Please try this

Javascript:'filter_query^ORDERBYcolumnName';

 

JagadishSanadi_0-1683790216645.png

 

 

Hello, @Jagadish Sanadi. The original question was about a catalog item variable, not a table column. Unfortunately, your suggestion is not applicable.