Sets the current sort order, key, and filters on a table.
- Type: RecordRef The RecordRef that refers to the table on which you want to set the current sort order, key, and filters.
- Type: Text or code The string format is the same as the SourceTableView Property on pages.
The value of the String parameter can be returned by the GETVIEW Function (RecordRef).
If the SETVIEW function is executed with an empty string, all the filters are removed and the primary key is used.
If no table is selected, the SETVIEW function fails.
This function works the same as the SETVIEW Function (Record).
The following example opens the Customer (18) table as a RecordRef variable that is named CustomerRecRef. The SETVIEW function sets the sort key to the Name field, sort order to Ascending and sets a filter that selects records between 1000 and 2000. The GETVIEW Function (RecordRef) 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 displayed in a message box. This example requires that you create the following variables and text constant in the C/AL Globals window.
|Text constant name||DataType||ENU value|
The following is the current sort order, key, and filters that are set: %1
CustomerRecRef.OPEN(18); CustomerRecRef.SETVIEW('SORTING(Name) ORDER(Ascending) WHERE(No.=CONST(10000..20000))'); ViewString := CustomerRecRef.GETVIEW; MESSAGE(Text000, ViewString);