The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.
SETVIEW Method (Record)
Sets the current sort order, key, and filters on a table.
The record in the table for which to set the sort order, key, and filters.
Type: Text or code
A string that contains the sort order, key, and filter to set.
The string format is the same as the SourceTableView Property on pages.
The value of the String parameter can be returned by the GETVIEW Method (Record).
If the SETVIEW method is executed with an empty string, all filters are removed and the primary key is used.
The following code example uses the SETVIEW method to set the sort key to the Name field and the sort order to Ascending, and sets a filter that selects records with the No. field between 1000 and 2000 in the Customer table. The GETVIEW Method (Record) method retrieves the sort order, key, and filters that have been set and stores the value in the ViewString variable. The value in the ViewString variable is then displayed in a message box. This example requires that you create the following global variables.
CustomerRec.SETVIEW('SORTING(Name) ORDER(Ascending) WHERE(No.=CONST(10000..20000))'); ViewString := CustomerRec.GETVIEW; MESSAGE('The string:%1', ViewString)