Walkthrough: Designing a Customer List Report
In Microsoft Dynamics NAV 2018, creating new reports is divided into the following phases:
Defining the dataset on which the report is based.
Designing and editing the visual layout of the report by using Visual Studio Report Designer.
About This Walkthrough
This walkthrough provides an overview of how to create a report that is based on one table with Dynamics NAV and design this report using Visual Studio Report Designer. This walkthrough illustrates the following tasks:
Create a report in Dynamics NAV.
Apply sorting criteria and filters on the report in Dynamics NAV.
Design the layout of the report in Visual Studio.
To complete this walkthrough, you will need:
Dynamics NAV with a developer license.
The CRONUS International Ltd. demo data company.
Microsoft Visual Studio installed. For more information about which version of Microsoft Visual Studio you need, see System Requirements for Microsoft Dynamics NAV. This walkthrough assumes that Microsoft Visual Studio 2012 or Microsoft Visual Studio 2013 is used.
Defining the Dataset
When you create a new report, you must define where the data that the report will display should come from. You define the dataset in Dynamics NAV Report Dataset Designer.
To define the dataset
In the Microsoft Dynamics NAV Development Environment, on the Tools menu, choose Object Designer.
In Object Designer, choose Report, and then choose the New button to open the Report Dataset Designer.
In the first row, in the Data Source field, choose the AssistEdit button. In the Table List window, select table 18, Customer, and then choose the OK button.
In Report Dataset Designer, on the first row, verify that the Data Type column is set to DataItem.
On the View menu, choose Field Menu.
In the Field Menu window, select the No., Name, Address, Phone No., and Country/Region Code fields, and then choose the OK button.
You can select multiple items by holding down the Ctrl key while you select.
When prompted to add these fields, choose Yes.
On the File menu, choose Save As.
In the Save As dialog box, in the ID field, enter 55551, and in the Name text box, enter Customer List.
Make sure the Compile check box is selected and choose the OK button.
Applying Sorting Criteria and Filters
Next, you will set the sorting criteria and filters that you want to use in the report. This report will sort the customers in ascending order by customer number. You will also provide filters on the request page that will enable users to filter the data based on the No. and Country/Region code.
To set the report properties
In Report Dataset Designer, select the DataItem row.
On the View menu, choose Properties.
In the Properties window, select the DataItemTableView property, and then, to open the Table View property window, choose the Value field.
In the Table View window, fill in the fields as shown in the following table.
Field Description Key Specify the field to sort the data items by, in this case the No. field. Order Specify the sort order, in this case Ascending.
Choose the OK button.
You will now add filters to the request page that will enable users to filter the data based on the No. or Country/Region Code, or both by default.
In the Properties window for the Customer data item, select the ReqFilterFields property, and then choose the Value field to open the Field List property window.
In the Field List window, specify the two fields that the data can be filtered by as shown in the following table.
Field No Country/Region Code
Choose the OK button.
On the File menu, choose Save.
In the Save window, make sure Compile is selected, and then choose the OK button.
Close the Properties window.
Designing the Report Layout
After you have saved and compiled the report in Report Dataset Designer, you must design the layout in Visual Studio. For this report, you will display all the fields that you selected, and display the company name in a larger font and set it to bold. You will also display the date, time, and username of the person who runs the report.
To design the layout of the report
On the View menu, choose Layout.
The report opens in Visual Studio. The report layout is empty.
In Visual Studio, on the View menu, choose Toolbox to open the toolbox.
From the Toolbox, drag a Table control to the report layout.
The table has only three columns, therefore, you will add two more columns to accommodate all the fields in the dataset.
Select the third column, open the shortcut menu, choose Insert Column, and then choose Right to add a new column. Repeat to add another column.
The next step is to populate the table with the data from the dataset.
To populate the list with data from the dataset
On the View menu, choose Report Data.
In the Report Data window, under Datasets, and under DataSet_Result, select each field and drag them from the dataset to the second row of the Data section of the report layout as described in the following table.
Field Column No_Customer First Name_Customer Second Address_Customer Third PhoneNo_Customer Fourth CountryRegionCode_Customer Fifth
From the Toolbox, drag three text boxes and put them above the table in the report designer. These text boxes will display the date and time, the username, and the company name.
Select the first text box, open the shortcut menu, and then choose Expression to open the Expression Properties window.
Under Category, choose Built-in Fields, double-click ExecutionTime, and then choose the OK button.
This expression displays the time the report was executed.
Select the second text box, open the shortcut menu, and then choose Expression to open the Expression Properties window.
Under Category, choose Built-in Fields, double-click UserID, and then choose the OK button.
This expression displays the user ID of the user who runs the report.
Select the third text box, open the shortcut menu, and then choose Text Box Properties to open the Text Box Properties window.
On the General tab, in the Value field, enter the company name. For this walkthrough, you can enter CRONUS International Ltd..
In the Textbox Properties window, on the Font tab, set the font size to a larger font, such as 14pt, and under Style, select Bold, and then choose the OK button.
You will format the text boxes for the field captions in the table to display in bold font.
On the report layout, resize the three text boxes to an appropriate size.
Select the No Customer caption text box, and choose Text Box Properties to open the properties window.
On the General tab, in the Value field, change the value to Customer No.
On the Font tab, and under Style, select Bold, and then choose the OK button.
Set the remaining caption text boxes to bold.
Save the Report.rdlc file, and then close Visual Studio.
Loading the Design Changes from Visual Studio and Running the Report
Now you will load the changes that you made in Visual Studio to Dynamics NAV to apply the changes to the Customer List report.
To load the design changes from Visual Studio and run the report
In Microsoft Dynamics NAV Development Environment, close Report Dataset Designer. A message informs you that the .rdlc file for this report has changed and asks if you want to load the changes. Choose Yes to save the changes in the database.
In the Save Changes window, make sure Compile is selected, and then choose Yes to save the report.
In Object Designer, select the report (55551) and choose Run. The request page is displayed.
In the request page, on the Customer tab, set the Country/Region Code filter to a country/region code and choose Preview to view the report. The report displays all the customers in the country/region code you selected.
You can filter the report by No. or Country/Region Code or both.
- Now you have created a report that lists customers by customer number or country/region code, and you have added changes to the report layout in Visual Studio. The next step is to add the customer list report to a page in the RoleTailored client from where it can be run. For more information, see How to: Make a Report Available from a Page.