Understanding report development

Report development is completely different from what it used to be. The report development experience changed in Dynamics NAV 2009 with the introduction of the Report Definition Language Client-side (RDLC) report, but it changes again with the actual release of the application.

With Dynamics NAV 2009, RDLC-based reports were introduced, but reports were still compatible with the classic definition of reports in Dynamics NAV. RDLC reports were actually based on the classic definition of the report.

From Dynamics NAV 2013, the reports classic definition has disappeared and only RLDC-based reports are available. This is why the report development experience has changed again. It now resembles the development experience of pages, queries, or XMLPorts.

Reports anatomy

Creating reports includes designing both the business logic that covers the kind of information the report will contain, and the layout that deals with how the report will look when it is printed.

In Microsoft Dynamics NAV 2016, to design a client report definition (RDLC), you design the data model with Report Dataset Designer and the layout with Visual Studio Report Designer. To do this, Visual Studio 2010 Professional or above is required.

Visual Studio Report Designer offers several new options and features. Furthermore, due to its thorough integration with Microsoft SQL Server, it is possible to take advantage of the reporting capabilities of Microsoft Report Viewer, including the following:

  • Richer formatting
  • Interactive sorting
  • Graphics and charts
  • Export possibilities (PDF, Microsoft Office Excel, and Microsoft Office Word)

A report object is composed of a report dataset and a visual layout. You design a report by first defining the dataset and then designing the visual layout. The report objects also contain properties, triggers, code, and an optional request page.

The following diagram shows components of a report and how they are related in Microsoft Dynamics NAV:

Reports anatomy

Reports in Dynamics NAV 2016 are executed in two steps, which reflect the two steps in the report design. The first is the data set design in C/SIDE followed by report layout design in Visual Studio.

The C/AL runtime retrieves the data from the involved source tables, performs the necessary calculations, and combines the data in a single flattened dataset. This is performed by the NAV server. The produced dataset is transferred to the report viewer's runtime hosted on the NAV client, which, in turn, renders the dataset data according to the report layout definition.

Defining the dataset

The dataset is defined on the Report Dataset Designer in the Microsoft Dynamics NAV Development Environment. The report dataset is built from data items and columns. A data item is a table. A column can be one of the following:

  • Field in a table
  • Variable
  • Expression
  • Text constant

Typically, the data items correspond to the fields in a table. When the report is run, each data item is iterated for all records in the underlying table with an appropriate filter defined.

When a report is based on more than one table, you must set relations between the data items so you can retrieve and organize the data. In Report Dataset Designer, you indent the data items to establish a hierarchy of data items and control how the information is gathered.

For example, to create a report that displays a list of customers and lists the sales orders that were placed by each customer, you must define the following data items:

  • A data item that corresponds to the Customer table
  • A data item that corresponds to the Sales Line table

You indent the second data item, which is the Sales Line table. As the report works through the records in the Customer table, it finds each customer's sales orders by examining the records in the Sales Line table that's related to the customer number.

The following screenshot shows the dataset definition of Report 108 Customer – Order Detail:

Defining the dataset

And this is how the dataset looks on Visual Studio:

Defining the dataset

Designing the visual layout

You build the visual layout of a report by arranging the data items. A report that is displayed or printed must have a client report definition (RDLC) layout. You use Visual Studio Report Designer to design the RDLC layout. You generally display most data in the body of a report, and you use the header to display information before any data item record is displayed. For example, you can display a report title, company, and user information in the header of a report.

With Visual Studio Report Designer, you can add useful features to your report layouts, such as:

  • Providing links from a field on a report to either a page or another report
  • Inclusion of images and graphs
  • The ability to toggle columns so you can hide or display data
  • The ability for the users to interactively change the column on which the data in the report is sorted
  • The ability to display RTF text

A report in Visual Studio always has exactly one body, and it is not possible to add more than one. Optionally, it can have one page header and one page footer. Extra headers or footers cannot be added. However, you can dynamically change the visibility property of objects on the report layout to control how the report will look.

When the report runs, it first runs the page header, then the page body, and then the page footer. It will not run the page body for each record. Looping through records is done by using a data region in the body section.

Reports use a variety of report items to organize data on a report page. The design surface is not what you see is what you get. The report items have an initial layout position that can change when the report is processed. The following list describes typical uses for different report items:

  • Textbox: It is used on titles, date stamps, and report names.
  • Table, Matrix: It is used to display tabular data from a report dataset. Table and matrix are templates of a Tablix data region and provide a starting grid layout for data from a report dataset.
  • Chart: It is used to graphically display data from a report dataset.
  • Gauge: It is used to present a visual image for a single value within a range of values.
  • List: It is used to create free-form layout, such as the forms on a web page.
  • Image: It is used to add existing images to a report.
  • Line: It uses lines as graphical elements.
  • Rectangle: It can be used as a container for other report items. Rectangles are often used to help control how the report items appear on a report page when the report is rendered.

The following screenshot shows the layout definition of the 108, Customer – Order Detail report:

Designing the visual layout

Tip

Detailed report writing using Visual Studio is beyond the scope of this book. For more in-depth detail on writing your own reports in Dynamics NAV, check out Microsoft Dynamics NAV 2015 Professional Reporting that's also published by Packt Publishing.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.125.219