Microsoft Dynamics 365 Business Central Views are used on list pages to define a different view of the data on a given page. Views can be defined for Pages, Page Extensions and Page Customization. A view offers:
- Filtering on multiple table fields on the source table defined for the page.
- Sorting of the data on multiple table fields, but only in one direction either ascending or descending.
- Layout changes, modifying page columns, moving them, etc.
Views are defined directly in code, on the list page that they modify. The defined view or views are available to the user through Filter Pane on a page and appear in the sequence that they are defined in code.
Microsoft Dynamics 365 Business Central Views Overview
1. Snippet Support
Typing the shortcut
tview will create the basic layout for a view when using the AL Language extension in Visual Studio Code.
2. Filtering and Sorting
You can filter on the data in a view by using the
Filters property. The following is an example of the syntax:
Filters = where (“Balance (LCY)” = filter (> 500), Name = filter (‘G*’));
You can sort on the data in a view by using the
OrderBy property. The following is an example of the syntax:
OrderBy = ascending (“Balance (LCY)”, Name);
3. View Example
The following example shows a page customization of the Customer List page, which is available for a specific role center only; the My Role Center. Change the role center view under My Settings.
The definition of the view adds a caption which is displayed on the left side in the UI. The view sorts the customer balance in ascending mode and the view modifies the layout by moving the customer balance first and adding a freeze column after it.
In general, views can in several ways be compared to page customizations. These are the limitations of views:
- For views you can modify the same control properties as for page customization objects independently of where the view has been defined (page, page extension or page customization level). This is validated by the compiler.
- It is not possible to use variables or methods in a view. When writing client side expressions for properties like Visibility, it will only be possible to use constant values or table field references. This is validated by the compiler.
- It is not possible to create new controls for a page from a view.
Views are defined on page extension objects to give an alternative view of data and/or layout on an already present page and in views on page customization objects, they can be utilized to provide an alternative view for a certain profile. For more details on Microsoft Dynamics 365 Business Central Views, please contact us.