Want to set reference field in descending order in catalog item

Priyanka Chaud1
Tera Contributor

Hi i want to set my table reference field to show data in descending form as latest data created first i tried but its now oworking anyone has solution for this how this works?

1 ACCEPTED SOLUTION

@Priyanka Chaud1 

this link has the solution.

it uses combination of variable attributes + query BR

https://www.servicenow.com/community/process-optimization-article/reference-field-autocomplete-sort-... 

Something like this

  1. Add the "ref_ac_order_by=sys_created_by" to the reference field.
  2. Create the before query business rule as below on your table:
    (function executeRule(current, previous /*null when async*/) {
       current.orderByDesc('sys_created_by');
    })(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Mohan raj
Mega Sage

Hi @Priyanka Chaud1,

 

This article will help you to achieve you requirement

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0725720

 

If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.

Hey @Mohan raj I want to set descending order in catalog item portal page you are giving solution for navigator please tell me

Priyanka Chaud1
Tera Contributor

Can u check this also @Ankur Bawiskar i am stuck here

@Priyanka Chaud1 

this link has the solution.

it uses combination of variable attributes + query BR

https://www.servicenow.com/community/process-optimization-article/reference-field-autocomplete-sort-... 

Something like this

  1. Add the "ref_ac_order_by=sys_created_by" to the reference field.
  2. Create the before query business rule as below on your table:
    (function executeRule(current, previous /*null when async*/) {
       current.orderByDesc('sys_created_by');
    })(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader