Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to sort the reference variable in DESC order in Catalog item

Manasa Allu
Tera Contributor

Hi team,

How to sort the reference variable in DESC order in the Catalog item.

 

Regards,

Manasa

 

8 REPLIES 8

hey, that works, but only in ascending order, any idea on how to do descending order? i tried adding ^DESC in the end, but didnt work

Hi OP/jennv

did you find a solution for descending order sorting?

hi @PrathamjeetS ,, yes i found it. i created a business rule in the table where my reference variable is.  Configured like this: 

when: before

on Query

in the script write: 

(function executeRule(current, previous /*null when async*/) {
   current.orderByDesc('sys_created_on');
})(current, previous);
 
 
 
@Manasa Allu would appreciate if you mark it as a solution. 🙂

Hi @jennv

Thank you and confirming that this is the correct approach. The only thing is that it did not work for me using the 'sys_created_on' date so I just used the 'number' field to sort which worked perfectly.