Question
There is a temporary table with a field h_insert (for further auto-filling). It is important that the data in h_insert is always sorted in ascending order by a field, for example, Customer Name. The field from which data is taken for h_insert is of type Select, and its id values do not match the Display. How to sort when selecting through selectList by the display (title) of the Select in the source table, and not by its base (value)?
Answer
The simplest way is to create a technical field (type string) in the table from which the selection is made. This field will use #s.select_field
to get its display (title) and sorting in the code in the selectList function in the h_insert
field by this technical field.
Sometimes adding a field is not suitable. In this case, you can take rowlist
and, in addition to field: 'select_field'
, take sfield: 'select_field'
. Then sort this rowlist
by title
and after that take the column with value
:
=: $sort[[value]]
sort: listSort(list: $rowlist; type: "string"; direction: "asc"; key: "title")
rowlist: selectRowList(table: 'table'; field: 'select_field' as "value"; sfield: 'select_field' as "title")
The first option adds a small resource overhead when performing any action in the table from which the selection is made. The second option adds overhead when performing the h_insert
calculation, as the select field code specified in sfield
will be calculated for each row.
The point at which it is preferable to transfer the load is determined individually for each specific system.