SETASCENDING Function (Record)
Sets the sort order for the records returned. Use this function after you have set the keys to sort after, using SETCURRENTKEY. The default sort order is ascending. You can use SETASCENDING to change the sort order to descending for a specific field, while the other fields in the specified key are sorted in ascending order.
For example, you can read data from an ODATA web service where the data is sorted in ascending order on the Name field but in descending order on the City field.
[Ascending :=]Record.SETASCENDING(Field,[ SetAscending])
Type: Record The record in the table that you want to set the sort order for.
Type: Field The field that you want to set the sort order for.
Type: Boolean The sort order. Specify
Descendingif data must be sorted in descending order; otherwise
The following code example illustrates how you can use SETCURRENTKEY and SETASCENDING to sort data in two different directions based on two fields.
In this example, you use SETCURRENTKEY to specify that you want to sort based on City and Name. This means that data will be sorted in ascending order based on those two fields, first by City, then by Name. Next, you use SETASCENDING to sort City in descending order instead. As a result, your data will look like this:
CTown ACustomer BCustomer BTown ACustomer BCustomer CCustomer ATown ACustomer BCustomer
SETCURRENTKEY Function (Record)