ORDERBY is not working for Lookup select box in service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2018 09:34 PM
Hi Team,
I have one catalog item where in I am using one lookup select box variable. I want the choices to be sorted out based upon on the department field in the reference table I am using for lookup.
I have used below code in advance qualifier of this lookup variable
javascript:getRequestType()
and this is refering to script include
script include
function getRequestType()
{
var query = 'u_parent='+current.variables.Application_Component+'^u_active=true'+'^u_service_request=cc00174a4f252b404c73cf5d0210c7e3'+'^ORDERBYu_department';
return query;
}
This is working perfectly fine in internal servicenow. However, not working on service portal. Please help me to fix this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2018 03:14 AM
Hi,
Thanks for looking into this. this is the complete attribute list which I have used now.
ref_qual_elements=Application_Component,ref_auto_completer=AJAXTableCompleter,ref_ac_columns=u_type;u_department,ref_ac_columns_search=true,ref_ac_order_by=u_department
still no luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2019 08:10 AM
I'm going to reach out to support to see if there is a known problem related to this... I've found LOTS of issues in community and only one "Known Error" so far (https://hi.service-now.com/kb_view.do?sysparm_article=KB0695435) and it's not quite the same issue... as described. I've found that it seems to break when you are passing the query via JavaScript.
For example we have a ref qual as
javascript: new RoleLookup().getAppsysID(current.variables.u_item_id);
That's doing this
getAppsysID: function(cat_item_id) {
//gs.info('passed value: ' + cat_item_id);
var grName = new GlideRecord('sc_cat_item');
grName.get(cat_item_id);
//gs.info('passed name: ' + grName.name);
var gr = new GlideRecord('cmdb_ci_appl');
gr.addQuery('name', grName.name);
gr.addQuery('subcategory', 'Application');
gr.query();
if (gr.next()){
//gs.info('passed query: ' + code_query);
code_query = 'u_application='+gr.sys_id+'^u_active=true^ORDERBYu_role_accesslevel';
}
return code_query;
we have the attribute as well... but it does not work. HOWEVER
if I plug in a query directly into the ref qual like this
u_application=833f7d71db8edb005b27f5961d961971^ORDERBYu_role_accesslevel
it will honor the ORDERBY.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2019 01:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2019 09:15 AM
So I got a reply from HI... Order by will not work via javascript: on a ref qual on Jakarta.
We are upgrading to Madrid and it does work there.... I never tested in K or L.
In Jakarta you have at least one option.
Set a display field on the table you are using in your Lookup Select and it will auto sort based on that. This will fix some issues... that helped me.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2019 10:10 AM
I can honestly say that, as of 12/19/2019, Madrid still does not support this 😞