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

Thanks Michelle,



Tried that too (so I had   u_type=excel^EQORDERBYsequence   ) but that still failed - as did EQORDERBYsequence^u_type=excel also



Each of the choices within has the value which the drop down appears to sort by.   Certainly within the internal tables in ServiceNow it sorts by sequence instead of value, so maybe something set globally at Service Catalog level could be setting the sort by value?


Good morning,

A few months on, and after our upgrade to Kingston, I've revisited this and still can't get it to play ball the way we'd like to.

The Sequence variable appears to be from the sys_choice table, and appears to be referenced in the choice list in the original post screenshot.   As the choice list is an element, not a table as such, I'm assuming we'd need a different way to reference it as it's not actually part of the u_it_training table as such.

Any ideas please?

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.

 

 

 

Is this still working for you?

We're trying to set this up in Madrid Patch 6 Hot Fix 1 and we can't get order to work on a Lookup Select Box variable.

Just an addition to this, we had the requirement of ordering a qualified/conditioned list and thought this may help others:

This was only achievable on the Lookup Select Box type and not on a reference type with advanced qualifier.

 

Reference qualifier: u_date_from>=javascript:gs.beginningOfToday()^EQORDERBYu_date_from

You need to add the ORDERBY after the ^EQ

find_real_file.png