Reference Field : How to sort the results in descending order using reference qualifier?

kutvaram
Tera Expert

Hi All,

I have a variable of reference field type with simple condition in it.

I need to sort the results by a column in descending order.

I used variable attributes section where ref_ac_order_by=columnname.

This is doing ascending order sorting.

How to do it descending order sorting by a column name?

I have referred many community links and also got to know , have to write query business rule. But I am not happy with that.

Kindly advise using variable attributes sorting by descending or a better way.

Thanks,

Ram Prakash K R

1 ACCEPTED SOLUTION

Can you try like this

var encodedquery = "sys_created_on>=2020-12-14^sys_created_on<=2020-12-15 23:59:59";

Thanks,

Narsing

View solution in original post

22 REPLIES 22

Narsing1
Mega Sage

Hi,

Remove everything from Variable Attributes & Reference Qual in your Reference Variable and Write this code in an Onload Client Script.

var vname = "<your reference variable name>";
var encodedquery = <pur your encoded query here>; //Ex: u_active=true
try {
            var ls = g_list.get(vname); 
            ls.reset();
            
            ls.setQuery(encodedquery + '^ORDERBYDESC<yourfieldnamehere>');
            
        } catch (e) {
            window[vname +'g_filter'].reset();
            window[vname + 'g_filter'].setQuery(encodedquery + '^ORDERBYDESC<yourfieldnamehere>');
            window[vname + 'acRequest'](null);
        }

Please mark it as correct answer if it solves your issue.

Thanks,

Narsing

Hi Narsing,

I tried the above script but the result is not correct.

Thanks,

Ram Prakash K R

Hi,

Is it possible to share screen shot of code and the variable as well.  I just tried and it is working for me.  

Thanks,

Narsing

 

Hi Narsing,

I written the code onLoad() of the catalog item?

Is it correct?

Thanks,

Ram Prakash K R

Hi Narsing,

Below is the code snapshot:

find_real_file.png