Lookup select box reference qual - sort by sequence

Warren Pilkingt
Mega Expert

Good morning,

We have a section on our ServiceNow instance where users can select a training course from a dropdown list, in this case Excel.

Currently the Lookup Select box has a reference qual containing u_type=excel so it filters on Excel only which refers to the IT training table:

find_real_file.png

The training table's choice list shows the courses and lists them with a sequence value as well as a label (just the Excel ones shown for reference):

find_real_file.png

However, when a user is using the service portal, the drop down list is sorted by the Value rather than the sequence, so labels appear in that order, instead of in the sequence order which is preferred.   I did try to add ^ORDERBYsequence to the end of the reference qualifier but that failed to change anything.

Although the values could be changed to be set alphabetically, would this impact on users who have already filled out the forms and selected a course where they've created a requested item already?   Or is there a way to ensure the order by is by sequence, so if more are added in future, we can always set the sequence order accordingly?

1 ACCEPTED SOLUTION

So I was able to resolve my own problem, it was a case of instead referencing the sys_choice table directly, but filtering out based on the dependent value being excel (effectively what the u_type field is set to):

find_real_file.png

So by ensuring that the value is the course field selected, with the label showing on screen as to which to be selected, it was then a case of narrowing down in the reference qual.

The element u_course is only used for IT training, although I could also add that in to the reference qual if it wasn't.

This then shows the courses in the order of sequence in the drop down list:

find_real_file.png

And if I change the sequence order, this order also changes, which is the behaviour we'd like. 

Just in case anyone else happens to need this, hope this helps.

 

 

 

View solution in original post

16 REPLIES 16

Hi Warren,

Hope you are doing well,

I need help. I want the same as your encountered.

Please help me to concat the your 'Sequence Logic' in below syntax,

ref qual -- javascript:'u_region='+current.variables.custom_region;

hello Vivek/Warren,

I too have a similar requirement. 

Can you please help on how to concat the your 'Sequence Logic' in below syntax,

ref qual -- javascript:'u_region='+current.variables.custom_region;

do you have any column on your table which will define the sequence ? if yes then you can use order by 

eg:

ORDERBY<fieldName>

In that case what will be syntax in ref qual - javascript:'ORDERBYsequence^u_region='+current.variables.custom_region;

the above is not working

 

ref qual -- javascript:'u_region='+current.variables.custom_region+'ORDERBYu_order';

have you try this,