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

MKelly83
Giga Expert

Hi warren



Just add ORDERBY and the column name to the reference qualifier should work.



E.g.


ORDERBYsequence^u_type=excel


Good afternoon Michelle,



I had tried that, and the order didn't change unfortunately.   It's almost as if it's defaulting to the value for ordering without it being specified in the reference qualifier.   Would rules be the next way to go?


Hi Warren,



Good way to do it is via user preference, this was an answer posted by palmen



I would assume you could set a user preference for this that is system wide so everyone should get it unless they change it themselves to something else.


The user preference should be


TABLE_NAME.db.order


The value should be the field name to sort on



You can also create a user preference named


TABLE_NAME.db.order.direction


The value should be ASC or DESC depending on if it should sort ascending or descending



Make sure to mark the System checkbox so it becomes systemvide



Example for Incident table


incident.db.order -> value = number


incident.db.order.direction -> value -> DESC


-Anurag

Try adding     ^EQ   before Sequence,



We do something similar and below works for us.



u_active=true^EQORDERBYu_sort