In Microsoft Dynamics NAV 2009, the process of creating new reports is divided into three phases:
-
Defining the data model on which the report is based.
-
Defining grouping and totaling for the report.
-
Designing the visual layout of the report.
With Microsoft Dynamics NAV, you can use Visual Studio Report Designer to design and edit the visual layout of a report.
About This Walkthrough
This walkthrough provides an overview of how to create a report that displays images, allows interactive sorting, and provides visibility toggling. This walkthrough illustrates the following tasks:
-
Defining the data model in Microsoft Dynamics NAV.
-
Designing the report layout using Visual Studio Report Designer.
-
Synchronizing the report layout with Microsoft Dynamics NAV and running the report.
-
Applying interactive sorting to the report layout using Visual Studio Report Designer.
-
Resynchronizing the report layout with Microsoft Dynamics NAV and running the report.
For more information about designing the layout of a report with Visual Studio, see Defining a Report Layout (Visual Studio Report Designer).
Prerequisites
To complete this walkthrough, you will need:
-
Microsoft Dynamics NAV 2009 with a developer license.
-
The CRONUS International Ltd. demo data company.
-
Visual Studio. For more information about versions of Visual Studio that you can use, see Requirements for Developing Reports for the RoleTailored Client.
Defining the Data Model
When you create a new report, you must define where the data that the report will display should come from. You define the data model in Microsoft Dynamics NAV.
To define the data model
-
In the Classic client, on the Tools menu, click Object Designer.
-
In Object Designer, click Report, and then click New to open the New Report window.
-
In the Table field, click the drop-down arrow, and then select the Item table with ID 27 in the Table List window.
-
Select Create a blank report, and then click OK. The Report Designer window opens.
-
In the DataItem field, select the Item table from the Table list, and then click OK.
-
On the View menu, click Sections to open Section Designer.
-
On the View menu, click Field Menu.
-
In the Field Menu window, select the No., Description, and Picture fields. Click on the design area twice to add the fields.
-
Close the windows, and then click Yes to save the report.
-
In the ID field, enter 50000, and name the report ItemReport.
-
Click OK.
Designing the Report Layout
Now that you have defined the data model for the report in Microsoft Dynamics NAV, you can design and refine the layout in Visual Studio.
To design the report layout in Visual Studio
-
In the Classic client, select the ItemReport that you created, and then click Design.
-
On the View menu, click Layout. The report opens in Visual Studio. The report layout is empty.
-
In Visual Studio, on the View menu, click Toolbox.
-
From the Toolbox, drag a Table to the report.
-
On the Data menu, click Show Data Sources.
-
From Data Sources, drag the Item_No_Caption field to the first column, first row of the table in the Header section of the report layout. Then drag the Item_No field to the first column, second row of the table in the Detail section of the report layout.
-
From Data Sources, drag the Item_DescriptionCaption field to the second column, first row of the table in the Header section. Then drag the Item_Description field to the second column, second row of the table in the Detail section.
-
From Data Sources, drag the Item_PictureCaption field to the third column, first row of the table in the Header section.
-
From the Toolbox, drag an Image to the third column, second row of the table in the Detail section.
-
On the View menu, click Properties Window.
-
In the Properties window, set the following properties.
Note When you set the Source property, the items in the MIMEType drop-down list change. You must set the Source property to Database so that the image/bmp value is available in the MIMEType drop-down list.
Property Setting Source
Database
MIMEType
Image\bmp
Value
=Fields!Item_Picture.Value
-
In the File menu, click Save Report.rdlc.
Synchronizing and Running the Report
Now you will load the changes that you made in Visual Studio to Microsoft Dynamics NAV to synchronize the two versions of the ItemReport.
To synchronize and run the report
-
In the Classic client, open ItemReport in Report Designer. A message informs you that the .rdlc file for this report has changed and asks if you want to load the changes. Click Yes to save the changes in the database.
-
On the Tools menu, click Compile to compile the ItemReport.
-
On the Windows taskbar, click Start, and then click Run.
-
In the Run window, enter the following text: DynamicsNAV:////runreport?report=50000, and then click OK.
-
Click Preview to view the report.
-
Close the report and run the report again with filter Picture set to 1. Only items that have associated pictures are printed.
-
Close the report.
Setting Up Interactive Sorting
The report now displays a list of items with a description and a picture of the item. You can filter the report to only view items that have a picture associated with them, as shown in step 6 in the preceding section. Now you will add interactive sorting to the ItemReport. Interactive sorting will allow users to interactively change the sort order for the data columns. By using the sort control button in the column header on the report, the user can change the sort order between ascending and descending.
To set up interactive sorting
-
In the Classic client, open the ItemReport in Report Designer.
-
On the View menu, click Layout. The report opens in Visual Studio.
-
Right-click the Item_No_Caption field, and then click Properties.
-
In the Properties window, click the Interactive Sort tab.
-
On the Interactive Sort tab, select the Add an interactive sort action to this textbox field.
-
In the Sort expression: field, select the expression =Fields!Item_No_.Value from the list, and then click OK.
-
Right-click the Item_DescriptionCaption header, and then click Properties.
-
In the Properties window, click the Interactive Sort tab.
-
On the Interactive Sort tab, select the Add an interactive sort action to this textbox field.
-
In the Sort expression: field, select the expression =Fields!Item_Description.Value, and then click OK.
-
Right-click the Image field, and then click Properties.
-
In the Properties window, click the Visibility tab, and then select the Visibility can be toggled by another report item field.
-
In the Report item: field, select Item_No_Caption, and then click OK.
-
In the File menu, click Save Report.rdlc.
Resynchronizing and Running the Report
After you have applied the latest changes to the report in Visual Studio, you will load the changes that you made in Microsoft Dynamics NAV to synchronize the two versions of the ItemReport. After the changes have been loaded, you can run the report to see the interactive sorting functionality.
To resynchronize and run the report
-
In the Classic client, open the ItemReport in Report Designer. A message informs you that the .rdlc file for this report has changed and asks if you want to load the changes. Click Yes to save the changes in the database.
-
On the Tools menu, click Compile to compile the ItemReport.
-
On the Windows taskbar, click Start, and then click Run.
-
In the Run window, enter the following text: DynamicsNAV:////runreport?report=50000, and then click OK.
-
Click Preview to view the report. You can use interactive sorting for the No. and Description columns. You can also collapse the list and display the No. and Description columns without pictures.
See Also
© 2010 Microsoft Corporation. All rights reserved.