Sorting a reference field

It may be right in front of me, but I can’t see it.

  • Let’s say you have a table called stage with three fields: id, sort order, text
  • You have another table with a reference field to that table: displaying the text field and storing the id

I would like to display the reference field drop down sorted by the sort order field so the stages are in order

I can’t seem to find the ability to specify the sort in data sources, or field override. Is this possible?

Generally if you want you model to be sorted in the same way whenever it is queried - add the field and direction clause to the “Fields to order records by” property on the Model. Use the field API name - probably something like sort_order DESC.

(But IIRC you are working with a PostGres database - and you will need to ensure that the field is sortable in the Data Source Table details (DSO Detail screen) . Go to the List view option and select the sort-order field to determine that it is defined as Sortable in its metadata.

Thanks Rob. Sorry if I am being stupid here. I am referring to sorting the reference field on a form, that is referencing another model, not a model. Does that make sense?

The client requires a non-alpha sorted drop-down list.

I have tried the following with (results):

  • Reference field going to a table (can’t find a way to sort the drop down non-alpha)
  • Reference field going to a sorted view (same result as above)
  • Picklist defined in data source (if you choose non-alpha, the UI will not allow you to put the list in an order that will be used in the form drop down)
  • Picklist with field override picklist on the model (this seems to work where the order I put them in is the order that appears in the drop down)

Reference (it would be nice to be able to specify a sort field on a reference field)

Picklist data-source UI (it would be nice if it would allow you to sort the pick list entries the way you want them displayed (like it does in the model field override)