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.

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

I had seen the first one and attempted the ref_ac_order_by variable attribute but was unsuccessful. An attribute already existed in that field so I appended ',ref_ac_order_by=u_version_sort_order' at the end. No change in behavior. 

I had not seen the second post but I have copy pasted my column name from my table multiple times. It would not hurt to attempt so again to be sure. I have been brought down my typos before.

I just verified my column name and copy pasted it into both the 'gr.orderBy' call as well as pasted it directly into the reference qualifier return. Neither had an effect. Thank you for the suggestion.

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

Sparsh C
ServiceNow Employee
ServiceNow Employee

you can set something like this in the reference qualifier of the Select Box variable:

javascript: 'ORDERBYname';

Sparsh C
ServiceNow Employee
ServiceNow Employee

Screenshot 2024-11-04 at 6.24.40 PM.png