Variable set > lookup select box > reference qualifier > script include

Brad59
Giga Guru

I have a Lookup Select Box on a variable set on a Catalog item that calls a script include in a reference qualifier and passes in the value of the previous Lookup Select Box into the script include. This script include returns a string value that is the reference qualifier. It works fine in returning the correct values. However, the string includes an 'ORDERBY' value that I cannot get the qualifier to honor. 

The u_version_sort_order value is an integer value in the table that is referenced by the Lookup Select Box.

I have tried putting the ORDERBY at the front and end of the string. 
I have tried ORDERBYDESC in both cases just to make sure I was not confusing things.
I attempted to not include the ORDERBY at all and instead use the ref_ac_order_by attribute on the select box.
Neither of the options above caused a changed in the order of the available options in the select box.

The 'return' statement in the script include that is called:

return 'sys_idIN' + returnObject + '^ORDERBYu_version_sort_order';

EDIT:

The the lookup select box is always ordered ASC by the values returned, which is u_version_name in my table:

find_real_file.png

I am attempting to get it to order by a u_version_sort_order so that we can account for oddities when strings with alphanumeric values are sorted. In the example below, I intentionally jumbled the version order so that it would be obvious if the lookup select list is sorted or not in testing:

find_real_file.png

 

1 ACCEPTED SOLUTION

Brad59
Giga Guru

I opened a Hi portal case for this. This is a known issue. You must switch the Type to Reference and use ref_ac_order_by in the variable attributes field. 

https://hi.service-now.com/kb_view.do?sysparm_article=KB0695435

View solution in original post

10 REPLIES 10

Jaspal Singh
Mega Patron
Mega Patron

Hi Brad,

 

In the script include itself where you do a GlideRecord & returnObject did you try applying sorting before the query(); itself. Can you try that once for a check i.e. to return the sys_ids in order before the query() itself.

Yes, I tried gr.orderBy() and gr.orderByDesc() with no change in behavior. I will try it again to be sure. 

I just tried this again and the order is still not honored. Thank you for the suggestion.

Alexandra9
ServiceNow Employee
ServiceNow Employee

Hi Brad, have you seen this and/or this post? I hope they are helpful :).