72
Chapter 9: Reports 9-1 CHAPTER 9: REPORTS Objectives The objectives are: Understand the concepts of reports and report components. Provide an overview of different report types and their characteristics. Describe the difference between the logical and the visual design of reports and introduce the Report Designer. Describe the logical design of a report. Create the data model for a new report by defining data items in the Report Designer. Describe the visual design of a report and introduce the Section Designer and Microsoft Visual Studio Report Designer. Create several types of sections for the report in the Section Designer. Improve the report by using some useful properties. Design the report layout for the RoleTailored client. Introduce the Request Options Designer. Design the request options form. Design the request options page. Understand the concepts of grouping in a report. Create grouping in the report by using table keys and indentation. Understand the concepts of totaling in a report. Create the subtotal and the grand total for one or more data items in the report. Create a grouping and totaling for the report in the RoleTailored client. Add some advanced features to the report. Introduction Reports print information from a database and they can structure and summarize information. Reports can be used to print documents such as invoices, and they can also be used to process data without printing anything. 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 addition, developing reports for the RoleTailored client requires additional design consideration. Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Na2009 enus devi_09

Embed Size (px)

Citation preview

Page 1: Na2009 enus devi_09

Chapter 9: Reports

9-1

CHAPTER 9: REPORTS Objectives

The objectives are:

• Understand the concepts of reports and report components. • Provide an overview of different report types and their

characteristics. • Describe the difference between the logical and the visual design of

reports and introduce the Report Designer. • Describe the logical design of a report. • Create the data model for a new report by defining data items in the

Report Designer. • Describe the visual design of a report and introduce the Section

Designer and Microsoft Visual Studio Report Designer. • Create several types of sections for the report in the Section

Designer. • Improve the report by using some useful properties. • Design the report layout for the RoleTailored client. • Introduce the Request Options Designer. • Design the request options form. • Design the request options page. • Understand the concepts of grouping in a report. • Create grouping in the report by using table keys and indentation. • Understand the concepts of totaling in a report. • Create the subtotal and the grand total for one or more data items in

the report. • Create a grouping and totaling for the report in the RoleTailored

client. • Add some advanced features to the report.

Introduction Reports print information from a database and they can structure and summarize information. Reports can be used to print documents such as invoices, and they can also be used to process data without printing anything.

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 addition, developing reports for the RoleTailored client requires additional design consideration.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 2: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-2

Reports Fundamentals In Microsoft Dynamics® NAV, reports have several purposes. They are as follows:

• Reports structure and print information from a database. For example, report 108, Customer - Order Detail lists all customers and all sales orders for each customer.

• Reports print and display documents in the application. For example, report 206, Sales - Invoice prints an invoice together with its relevant information.

• Reports are used to automate many recurring tasks, such as updating all prices in the item list. This can be performed by using C/AL code in a codeunit, but to use a report makes it much easier because of the powerful data modeling available for report design. For example, report 794, Adjust Item Costs/Prices.

A report consists of the report description. The report description specifies how data is collected and presented on the screen or printed on the paper when the report is run.

The report description is not directly visible to the user. When a developer creates a report, he or she assigns the report name, ID number, specifies data items and designs the visual element of the report. This establishes the report description.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 3: Na2009 enus devi_09

Chapter 9: Reports

9-3

The report description contains properties, triggers, sections, controls, a request form, a request page and RDL data. The last two components are required for reports that are developed for the RoleTailored client. The following shows components of a report and how they are related:

FIGURE 9.1 REPORT COMPONENTS AND THEIR RELATION

Properties

The report description contains properties that are related to the report itself and properties that are related to the other components of the report, such as data items, sections, request form or request page.

A property is an attribute of an object, or its component, that characterizes and specifies behavior of the parent in some ways, such as whether it is visible.

Triggers

Certain predefined events that occur to a report cause the system to execute a user-definable C/AL function. The event and the function together are called a trigger.

Triggers in a report can be divided into six categories:

• Report triggers • Data item triggers • Section triggers • Request form triggers

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 4: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-4

• Request page triggers • Control triggers

Examples of report triggers include OnPreReport that contains statements that are executed right before the report is run, and OnPostReport that contains statements that are executed right before the report execution is completed. Triggers in a report are edited in the C/AL Editor which is accessed from the Report Designer.

Data Items

The data model of a report is built from data items. A data item corresponds to a table. When the report is run, each data item is iterated for all records in the underlying table. When a report is based on more than one table, establish a hierarchy of data items to control how the information is collected by indenting data items.

For example, to create a report that prints a list of customers, and also sales orders created by each customer, define two data items:

• One that corresponds to the Customer table. • One that corresponds to the Sales Order table.

The second data item is indented - as the report works its way through the records in the Customer table, for each customer, all sales orders that are related to this customer must be found by going through the records in the Sales Order table.

Sections

Reports in Microsoft Dynamics NAV can be a printing or nonprinting report. A nonprinting report is used for processing a certain task and does not produce a displayed output. A printing report displays the result in the screen or prints output on the paper. This display is controlled by the visual element of the reports. In Microsoft Dynamics NAV, there are two different visual elements, they are as follows:

• Classic report layout which is the report sections. • Client report definition which is the RDL data.

A section is a visual element of a report. It can be thought of as a block of information to print on the paper. In a printing report, each data item can have one or more sections. The report itself is composed of several sections, including those that are printed:

• Only one time, such as a grand total. • One time per page, such as a header. • For each record that is retrieved from the database.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 5: Na2009 enus devi_09

Chapter 9: Reports

9-5

The visual element of a report includes the sections. In a printing report, one or more sections can be attached to each data item. There are several types of sections. Each has a specific function. Usually, the bulk of the data is printed in the Body section of a data item, whereas the Header section of the data item is used to print information before any record of the data item is printed, such as column captions. There can be reports where the Body section is not used at all, and all information is printed in other sections.

The report in the following figure prints sales statistics information and retrieves all its data from one table. It demonstrates a range of the features that are available for designing reports:

• Before any record from the table is printed, there is a header that contains a title and information about the filter that is used on the customer numbers.

• Each Body section prints information about a customer on several lines. The "Profit %" lines are calculated as the report is run.

• After all records selected by the filter are printed, a Footer section is printed that contains totals for the selected customers.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 6: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-6

• In the Body section and in the Footer section, a filter is applied to create columns where data is collected and totaled for different periods.

FIGURE 9.2 THE SALES STATISTICS REPORT

Controls

The information that is printed in the sections is made of controls. The available controls are as follows:

• Text boxes - They are used for printing the result of the evaluation of any valid C/AL expression, such as the contents of a table field. They are also used for printing the results of complex calculations.

• Labels - They are used for printing static text, such as a caption for a column of data.

• Shapes, images, and picture boxes - They are used for printing bitmap pictures and graphical elements, such as lines and circles.

Controls are also available in the request form and the request page.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 7: Na2009 enus devi_09

Chapter 9: Reports

9-7

Request Form

The request form is the form that is run before the actual report begins execution. It is used to collect requests and options from the user of the report of things such as sort order or level of detail. The request form is run when the report is run in the Classic client.

Request Page

The request page has the same purpose as the request form, to collect request and options from users before the actual report begins execution. The request page is run when the report is run in the RoleTailored client.

RDL Data

The RDL data is also a part of the visual element of a report. The RDL data is used, instead of the sections, when the report is run in the RoleTailored client. The RDL data is designed in Microsoft Visual Studio Report Designer which is accessed from the C/SIDE Report Designer.

Types of Printing Reports There are several types of printing reports in Microsoft Dynamics NAV. The types of reports are not as strictly established as compared to the types of pages, or even to types of forms and tables.

List Reports

A List report prints a list of records from a table. A List report usually contains a single data item. This data item represents the table being listed. The table is either a Master table or a Supplemental table.

Each column contains a field from the table. Most data are printed from that table and sometimes brought in or calculated from other tables.

The name of the List report is usually the name of the table followed by the word List.

The following are examples of List reports:

• Report 101, Customer - List • Report 301, Vendor - List

Test Reports

A test report is printed from a Journal Table. Its purpose is to test each Journal Line according to certain criteria that are used for posting so that all the errors can be found and fixed before posting.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 8: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-8

As soon as an error is found during posting, processing stops and the error must be fixed before posting can be tried again. Therefore, a test report is a good way to find errors in a journal that has multiple errors.

The name of the Test report is usually the name of the corresponding Journal, followed by the word Test.

The following are examples of Test reports:

• Report 2, General Journal - Test • Report 1005, Job Journal - Test

Posting Reports

A Posting report prints from the Register table. It lists all the transactions (ledger entries) that are posted into that Register. A Posting report can be printed as part of the Post and Print option in a Journal.

The name of the Posting report is usually the name of either the Register table or the Master table of the corresponding ledger entries.

The following are examples of Posting reports:

• Report 3, G/L Register • Report 103, Customer Register • Report 1015, Job Register

Transaction Reports

A Transaction report has the following characteristics:

• It lists all the ledger entries for each record in the Ledger table. • It contains a subtotal for each Master table record, and a grand total

for all tables printed. • It is used to view all transactions for a particular Master record. • It has no standard naming convention.

A Transaction report usually has one or more data items, including the Master table and the corresponding Ledger table.

The following are examples of Transaction reports:

• Report 4, Detail Trial Balance • Report 104, Customer - Detail Trial Bal. • Report 1007, Job - Transaction Detail

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 9: Na2009 enus devi_09

Chapter 9: Reports

9-9

Document Reports

A Document report prints a document. Document reports differ from most other reports, in that, many of the fields are not displayed in columns.

An example of this type of report is the Sales Invoice. The header information in a Sales Invoice is printed as if filling out an invoice document. This header information is repeated at the top of each page, and no page has information from more than one header.

The lines for the invoice print more like an ordinary report in rows and columns. The lines correspond to the header on the same page, and lines from other invoices are not displayed on the same page.

The following are examples of Document reports:

• Report 206, Sales - Invoice • Report 116, Statement • Report 405, Order

Other Reports

Reports are more loosely defined than other application objects because they are frequently customized for a particular client. However, most reports consist of a tabular listing with records listed horizontally and each field displaying in its own column. Many times, there is a group heading or total to split the lines among various categories and to subtotal the lines by the categories.

The following are examples of other reports:

• Report 113, Customer/Item Sales • Report 313, Vendor/Item Purchases • Report 1012, Jobs per Customer

Report Design Process The report design process is divided into two distinct phases that reflect different aspects of creating a report. They are as follows:

• Defining the logical structure (the data model). • Designing the visual element.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 10: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-10

In addition, there are occasions where a user must be able to input certain options before running the report through a request form or request page. Therefore, the report design process also includes the following:

• Designing the request form. • Designing the request page.

Logical Design

The logical design of a report means defining the data model, meaning, defining how the data for the report is collected. This includes the following:

• Defining the tables that are used by the report, by defining data items.

• Defining relationships between data items if the report uses more than one table.

• Defining the key, sort order, and filters to use with the data items. • Defining which elements the user can change at run time. • Defining how data is to be grouped. • Defining how subtotals and totals are to be calculated. • Writing C/AL code in data item triggers to obtain advanced

functionality.

Visual Design

The visual design of a report means designing the report's visual elements which involves the following:

• Creating report sections for a report that is run in the Classic client. • Creating RDL data for a report that is run in the RoleTailored client.

The Report Designers

Both logical and visual design of the report is defined in the Report Designer which is accessed from the Object Designer.

The Report Designer contains three additional designers:

• The Section Designer which is used to design the report sections. • The Request Options Form Designer which is used to design request

options forms. • The Request Options Page Designer which is used to design request

options pages.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 11: Na2009 enus devi_09

Chapter 9: Reports

9-11

There is also one external designer which is:

• Microsoft Visual Studio Report Designer which is used to create the RDL data for layout of reports in the RoleTailored client.

The following steps show how to open the Report Designer:

In Microsoft Dynamics NAV Classic Client:

1. On the Tools menu, click Object Designer. 2. Click the Report button to open the Report list. 3. Select any report and then click the Design button to open the Report

Designer and design the report, or click the New button to open the Report Designer and design a new report.

Design the Data Model The data model is defined in the Report Designer window, by adding data items. In this window, specify the tables that the report reads. Any table listed in this window is read in its entirety when the report is run. To limit the number of records the report reads, link and filter data items.

A report can read the same table multiple times (in the same report) if the table is listed multiple times in the Report Designer. For example, a report can be set up to read the customer records two times, first the customers that are not blocked, and then the customers that are blocked.

The listed tables become data items in the report. Data items are record variables that enable the report to access the data of a table. The following figure shows the Customer List report in the Report Designer.

FIGURE 9.3 THE CUSTOMER LIST REPORT

The Customer table is the data item for this report. The Name column in the Report Designer displays the name that is used by the report for the data item. Just as all variable names, these names must be unique within the report.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 12: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-12

Ordering and Indenting Data Items

The order in which the data items are listed is the order in which the report reads the data from the tables. At the bottom of the Report Designer window, there are four arrow buttons. Use the up and down arrow buttons to reorder the data items and use the right and left arrow buttons to indent or unindent a data item.

If a data item is indented under another data item (parent data item), for every record read from the parent data item, all records are read from the indented data item, taking into account any filters or links.

This concept is similar to a nested FOR loop. For example, if the Sales Line table is added as a data item under the Customer table, and then indented, the report reads a customer, and then the relevant sales line information for that customer, before moving to the next customer and that next customer’s sales lines.

Linking a Data Item

Each data item has the DataItemLinkReference property and the DataItemLink property. These properties are used to define a Master/Detail relationship between two tables.

In the DataItemLinkReference property of a data item, select the parent data item to link to (the data item must be indented under the parent data item.)

In the DataItemLink property of the indented data item, specify a filter for this data item by matching fields in this data item with fields from the parent data item in the DataItemLinkReference property.

Demonstration: Create a Data Model Several demonstrations here help to understand some of the basic design principles of creating a report in Microsoft Dynamics NAV. The report created in these demonstrations, shows a list of customers by salespersons.

The following demonstration shows how to create a data model by defining data items, create linking between the data items and define appropriate sorting for the data item in the Report Designer.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 13: Na2009 enus devi_09

Chapter 9: Reports

9-13

Prepare the Customer Table

Before getting started with the report, add a key to the Customer table:

1. Design table 18, Customer, from the Object Designer. 2. Click View, Keys and add Salesperson Code to the list of keys.

FIGURE 9.4 THE CUSTOMER TABLE KEYS

3. Close the Keys window and compile, save, and close the table.

Create the Report Data Model

The following steps show how to create the business logic for the report in the Report Designer:

1. In the Object Designer's Report List, click the New button. The New Report window opens. In this demonstration, do not use the Report Wizard.

2. Select Create a Blank Report and then click the OK button. The Report Designer opens.

3. Click the first empty line in the Report Designer, and type or select the number or name of table 13, Salesperson/Purchaser in the DataItem column. By the default, the Name column is set to the table name.

4. Click the next line, and add the table 18, Customer.

The report must show customers by salesperson. Therefore, it must first read the Salesperson/Purchaser table, and for each salesperson record, it must read all the customers for that salesperson. To do this, indent the Customer data item under the Salesperson/Purchaser data item, and link the two.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 14: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-14

5. While the Customer data item is still selected, click the right arrow button at the bottom of the Report Designer to indent the Customer data item.

FIGURE 9.5 THE CUSTOMER DATA ITEM INDENTED UNDER THE SALESPERSON/PURCHASER DATA ITEM

6. Open the Properties window for the Customer data item. 7. Locate the DataItemLinkReference property, and verify that it is set

to Salesperson/Purchaser. 8. Locate the DataItemLink property and click the Assist-Edit button

on the DataItemLink property. The DataItem Link window opens. 9. Type the following in the DataItem Link window:

Field Reference Field Salesperson Code Code

This links the Salesperson Code field from the Customer table to the Code field from the Salesperson/Purchaser table.

10. Click OK to close the DataItem Link window. Notice that the DataItemLink property is set to Salesperson Code=FIELD(Code).

11. Locate the DataItemTableView property and then click the Assist-Edit button on the DataItemTableView property. The Table View window opens.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 15: Na2009 enus devi_09

Chapter 9: Reports

9-15

12. In the Key field, select Salesperson Code, and then click OK to close the Table View window. Notice that the DataItemTableView property is set to Sorting(Salesperson Code). This sorts the indented data item by the indicated field. This is a good practice when linking two data items.

FIGURE 9.6 THE CUSTOMER DATA ITEM PROPERTIES

13. Close the Properties window. 14. Compile and save the report by clicking File, Save As. The Save As

dialog box opens. 15. Type 90000 in the ID and Customer by Salesperson in the Name,

ensure that the Compiled check box is selected, and then click OK. This compiles and saves the report.

The report data model is now completed. The next step is to design the visual element of the report.

Design the Visual Element Reports can be run from both the Classic and the RoleTailored client. The report's visual elements are designed in the Section Designer and the Microsoft Visual Studio Report Designer.

The Section Designer

The Section Designer is used to design the visual element (report sections) of a report, section-by-section. Each data item can have one or more sections. The Section Designer is accessed from the Report Designer. The following steps show how to open the Section Designer.

1. Open the Report Designer from the Object Designer. 2. In the Report Designer, click View, Sections.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 16: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-16

NOTE: If the report has its Processing Only property set to Yes, no sections can be created.

A section is a sub-object of a data item. To create a section, select the data item that the section is associated with, and specify a type of section. To delete a section, in the Section Designer, click the gray bar for the section and press F4. There are several types of sections available to a data item. The following list shows a brief description of the types of sections in a report:

Section Description

Body This section prints one time for every record that is processed by the data item. If a record is skipped or filtered out, this section does not print for that record.

Footer This section prints last for a data item. By default it only prints one time every time that the data item is processed, but it can be set to print on every page. This section can be specified to be printed at the bottom of the page.

GroupFooter This section prints right after the last record in a group that is processed. This section only prints if the GroupTotalFields property for the data item is set, and the data item is appropriately sorted.

GroupHeader This section prints right before the first record in a group that is processed. This section only prints if the GroupTotalFields property for the data item is set, and the data item is appropriately sorted.

Header This section prints first for a data item. By default, it only prints one time every time that the data item is processed. However, it can be set to print on every page.

TransFooter This section prints at the bottom of a page for a data item that is continued on the next page.

TransHeader This section prints at the top of a page for a data item that is continued from the previous page.

Each section works like a small form, with the SourceTable property set to the data item's table. Controls on sections have no triggers, but have the same properties as controls in a form.

NOTE: Colors are visible for controls that are set in the Section Designer; however, these colors do not print when the report is run. The only way to print colors is to use Image or PictureBox controls.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 17: Na2009 enus devi_09

Chapter 9: Reports

9-17

Microsoft Visual Studio Report Designer

The RDL Data is a report component that is used by Microsoft Dynamics NAV to display the report in the RoleTailored client. Microsoft Visual Studio Report Designer is an external designer that is used to design the visual element (the RDL data) of a report to be run in the RoleTailored client. It is accessed from the Report Designer. The following steps show how to open the Microsoft Visual Studio Report Designer.

1. Open the Report Designer from the Object Designer. 2. In the Report Designer, click View, Layout.

The Report Designer provides two options about layout creation:

• Create Layout Suggestion • Delete Layout

These two options can be accessed on the Tools menu in C/SIDE.

The Create Layout Suggestion option creates a suggestion for the report layout in Microsoft Visual Studio Report Designer based on the sections designed in the Section Designer. The Delete Layout option deletes the current report layout. If a report without RDL data (no layout is defined in Visual Studio) is run in the RoleTailored client, it is run as if in the Classic client.

Demonstration: Design the Report Section The following demonstration shows how to create different types of sections in the Section Designer and examines the effect of data item indentation and linking to the report sections.

Design Sections

The following steps show how to design the visual element of a report by adding several sections and controls to the report in the Section Designer.

1. Design report 90000, Customer by Salesperson from the Object Designer.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 18: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-18

2. Click View, Sections. The Section Designer opens. There are two sections already created for the report: the Salesperson/Purchaser, Body (1) and the Customer, Body (1). Both are Body sections of each data item. The number in the brackets indicates that they are the first section of their respective data item.

FIGURE 9.7 THE SECTION DESIGNER

3. Click the Salesperson/Purchaser Body section, and then Press F3

to insert another section. The Insert New Section window opens. 4. Select Salesperson/Purchaser in the Data Item drop-down list, and

select the Header in the Section Type option, and then click OK.

FIGURE 9.8 THE INSERT NEW SECTION WINDOW

A Header section for the Salesperson/Purchaser data item is inserted in the Section Designer. The Header section for a data item is always located before the Body section. The Body section of the Salesperson/Purchaser data item now has the number 2 instead of 1, because it is now the second section of that data item.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 19: Na2009 enus devi_09

Chapter 9: Reports

9-19

5. Repeat step 4 to insert a Header section for the Customer data item.

FIGURE 9.9 THE SECTION DESIGNER

The report now has four sections. They have no control on them. If the report is run, nothing appears in the screen or prints in the paper.

6. Click the Salesperson/Purchaser Body section, and then click View, Field Menu. The Field Menu window opens.

7. Press and hold the CTRL key, and select the Code and Name fields. 8. Place the cursor over the Salesperson/Purchaser Body section and

then click to enable the Section Designer, and then click to put the fields on the section. Notice that the labels and text boxes are created differently on a report section than on a form. The labels are positioned above the text boxes in columns. Move the controls around just as if in forms.

9. Drag the labels one at a time from the Body section to the Header section of the Salesperson/Purchaser data item and line them up above the corresponding text boxes.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 20: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-20

10. Repeat steps 7 to 9 for the Customer Body section. Add the No., Name, City, and Phone No. fields from the Customer table. Move the labels to the Header section of the Customer data item.

FIGURE 9.10 THE SECTION DESIGNER

11. Compile, save, and close the report.

Run the Report in the Classic Client

The following steps show how to run a report in the Classic client.

1. In the Object Designer's Report list, select report 90000, Customer by Salesperson, and then click the Run button.The request form opens.

FIGURE 9.11 THE REQUEST FORM

This form enables users to enter filters for the data items or change the sorting of the data items. Users can also select to print or preview the report. There is only one tab in the form which is the Salesperson/Purchaser tab. This tab corresponds to the Salesperson/Purchaser data item. By default, each data item has a tab in the request form. In this case, the tab that corresponds to the Customer data item is hidden, because the Customer data item is sorted (the DataItemTableView property is set) and the ReqFilterFields property is not set.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 21: Na2009 enus devi_09

Chapter 9: Reports

9-21

2. Click Preview.

FIGURE 9.12 THE PRINT PREVIEW WINDOW IN THE CLASSIC CLIENT

The report shows all salespersons and all their customers.

NOTE: To be able to print or preview any reports, at least one printer driver must be loaded in the client PC.

Examine the Effect of Indentation and Linking

The following steps show the difference in the sections without indentation and linking.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Sections to open the Section Designer.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 22: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-22

3. Insert a Footer section for each data item. 4. On the footer for each data item, add a label from the Toolbox, and

change the caption for each to SP-Footer and Cust-Footer respectively.

FIGURE 9.13 THE SECTION DESIGNER

5. Close the Section Designer.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 23: Na2009 enus devi_09

Chapter 9: Reports

9-23

6. Compile and save the report. 7. Click File, Run to run the report, and then click the Preview button

in the Request Form.

FIGURE 9.14 THE FOOTER SECTION

The report shows all salespersons and their customers. The Footer section for the customer is printed for every salesperson that has customers. In this case it is printed two times. (There are only two distinct salespersons that have customers.) The Footer section for the salesperson is printed one time, at the end of the report.

8. Close the report preview. 9. Click the Customer data item and then click the left arrow button at

the bottom of the Report Designer to unindent the Customer data item.

10. Open the Properties window for the Customer data item and clear the values of the DataItemLink property.

11. Close the Properties window and then run and preview the report.

Without the indentation, the report shows all salespersons and then all customers. The Footer section of each data item is printed one time, right after the iteration of each data item is finished.

12. Close the report preview.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 24: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-24

13. Click the Customer data item and then click the right arrow button at the bottom of the Report Designer to indent the Customer data item.

14. Run and preview the report.

With indentation but no linking, the report shows all salespersons and for each salesperson, all customers. The Footer section for the Customer data item is printed for every salesperson. The Footer section for the Salesperson data item is printed one time, at the end of the report.

15. Close the report preview and close the report without saving it.

Use the PrintOnEveryPage Property

The customers for some salespersons extend to more than one page. However, on the second page, the report does not print any headings that indicate which salesperson that the customers are associated with. The following steps show how to use the PrintOnEveryPage property of the section.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Sections to open the Section Designer. 3. Select each Header section on the report and change the

PrintOnEveryPage property of the Header section to Yes.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 25: Na2009 enus devi_09

Chapter 9: Reports

9-25

4. Compile, save and close the report. 5. Run and preview the report.

FIGURE 9.15 THE HEADER SECTION AFTER SETTING THE PRINTONEVERYPAGE PROPERTY

The Salesperson header and the Customer header appear at the top of every page. This still does not tell which salesperson those customers are associated with. A section that prints at the top of the pages that are continuations of the previous page and show the current salesperson is needed. This is the purpose of TransHeader sections.

Add a TransHeader

First, determine which data item is for the TransHeader section and then determine which data item the report is in the middle of printing when it extends to the next page. In this case, a TransHeader for the Customer data item is needed. The following steps show how to add a TransHeader section to the report.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Sections to open the Section Designer. 3. Insert a TransHeader section for the Customer data item.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 26: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-26

The TransHeader section is positioned between the Header and the Body sections of the data item. In the Customer TransHeader section, display the current salesperson.

4. Click the Salesperson Body section, and select both the Code and Name fields.

5. Click Edit, Copy or press CTRL+C to copy these controls to the clipboard.

6. Click the Customer TransHeader section, and then click Edit, Paste or press CTRL+V to paste the two controls to this section.

7. Align the controls with the original controls.

To display fields from the Salesperson data item in the Customer TransHeader section, include the Salesperson data item in the SourceExpr property of the controls.

8. Open the Properties window for the Code text box in the Customer TransHeader section and set the SourceExpr property to "Salesperson/Purchaser".Code.

9. Repeat step 8 for the Name text box, but change the SourceExpr property to "Salesperson/Purchaser".Name.

10. Close the Properties window. 11. Add a label to the Customer TransHeader section with caption

Continued.

FIGURE 9.16 THE CUSTOMER TRANSHEADER SECTION

12. Close the Section Designer and compile, save, and close the report. 13. Run and preview the report.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 27: Na2009 enus devi_09

Chapter 9: Reports

9-27

Add a TransFooter

A TransFooter works exactly like a TransHeader. However, it prints at the bottom of the page that is to be continued. The following steps show how to add a TransFooter section to the report.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Sections to open the Section Designer. 3. Insert a TransFooter section for the Customer data item. 4. Add a label to the Customer TransFooter section with caption

Continued.

FIGURE 9.17 THE CUSTOMER TRANSFOOTER SECTION

5. Close the Section Designer and compile, save, and close the report. 6. Run and preview the report.

Demonstration: Modify Report Properties The following demonstration shows how to improve the report by setting some useful properties.

Use the NewPagePerRecord Property

The NewPagePerRecord property is used to create a page break whenever the report shows a new record. The following steps show how to use the NewPagePerRecord to set the Customer by Salesperson report to start a new page for every salesperson.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 28: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-28

2. Open the Properties window for the Salesperson/Purchaser data item and set the NewPagePerRecord property to Yes.

3. Close the properties window and compile, save and close the report. 4. Run and preview the report.

FIGURE 9.18 THE REPORT PREVIEW AFTER SETTING THE NEWPAGEPERRECORD PROPERTY

Use the PrinOnlyIfDetail Property

The PrintOnlyIfDetail property is used to limit printing a data item that does not have a detailed data item. For example, the report does not show any customers for salesperson Annette Hill. She is not really a Salesperson. She is a Purchaser. The following steps show how to use the PrintOnlyIfDetail property to change the report to only include those salespersons that actually have Customers.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Open the Properties window for the Salesperson/Purchaser data item and set the PrintOnlyIfDetail property to Yes.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 29: Na2009 enus devi_09

Chapter 9: Reports

9-29

3. Close the properties window and compile, save and close the report. 4. Run and preview the report.

FIGURE 9.19 THE REPORT PREVIEW AFTER SETTING THE PRINTONLYIFDETAIL PROPERTY

Use the ReqFilterFields Property

The ReqFilterFields property is used to specify which fields the user sees on the request form that can be used for filtering. The following steps show how to use the ReqFilterFields property to let filtering on the Code and Name fields of the Salesperson/Purchaser table on the request form.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Open the Properties window for the Salesperson/Purchaser data item and set the ReqFilterFields property to Code,Name.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 30: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-30

3. Close the properties window and compile, save and close the report. 4. Run the report and view the request form.

FIGURE 9.20 THE REQUEST FORM AFTER SETTING THE REQFILTERFIELDS PROPERTY

NOTE: Sorting a data item (setting the DataItemTableView property) that does not have ReqFilterFields causes its tab on the request form to disappear.

Use the ReqFilterHeading Property

The ReqFilterHeading property is used to change the name of the tab on the request form. By default, the name of the tab follows the name of the data item. The following steps show how to use the ReqFilterHeading property to change the Salesperson/Purchaser tab on the request form to only Salesperson.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Open the Properties window for the Salesperson/Purchaser data item and set the ReqFilterHeading property to Salesperson.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 31: Na2009 enus devi_09

Chapter 9: Reports

9-31

3. Close the properties window and compile, save and close the report. 4. Run the report and view the request form.

FIGURE 9.21 THE REQUEST FORM AFTER SETTING THE REQFILTERHEADING PROPERTY

Demonstration: Design the Report Layout The following demonstration shows how to design the report layout in Microsoft Visual Studio Report Designer for a report to be run in the RoleTailored client.

Prepare the Layout

The following steps show how to design the report layout in Microsoft Visual Studio Report Designer.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Layout. Microsoft Visual Studio Report Designer opens with a Dataset Result from the report section.

NOTE: The name of each field in the dataset is created from the DataSetFieldName property of each control in the report section. If this property is not defined, C/SIDE assigns a default name, and then set the DataSetFieldName property. C/SIDE also creates the caption and the format fields (the fields that have the suffix Caption and Format.) Use the caption fields for column headers (or other text purposes) instead of hard-coded text and use the format fields to set the Format property of the respective fields (usually decimal fields.)

3. Drag a Table control from the toolbox to the report layout.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 32: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-32

4. Click one of the columns, right-click and then click Insert Column to the Right.

5. Repeat step 4 two times to add two more columns.

FIGURE 9.22 THE TABLE WITH SIX COLUMNS

Now, the layout has a table with six columns.

NOTE: Instead of designing the layout manually, try the Create Layout Suggestion by clicking Tools, then Create Layout Suggestion in the Report Designer, and modify from there when it is necessary. This overwrites the current layout, if any.

Add Column Headers

The following steps show how to add column headers to the report layout.

1. Drag the Salesperson_Purchaser_CodeCaption from the DataSet Result to the first column of the first row of the table.

NOTE: Use the caption fields for column headings instead of hard-coded text, to support a multilanguage scenario.

2. Repeat step 1 for the Salesperson_Purchaser_NameCaption, Customer__No__Caption, Customer_NameCaption, Customer_CityCaption and Customer__Phone_No__Caption fields from the DataSet Result to the appropriate columns of the first row of the table.

NOTE: These can also be achieved by going to the individual text box in the table and typing the Value property appropriately.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 33: Na2009 enus devi_09

Chapter 9: Reports

9-33

Now, the layout looks as follows:

FIGURE 9.23 THE REPORT LAYOUT

Add a Grouping

A dataset result in Visual Studio is flattened data. This means the Salesperson/Purchaser table and the Customer table are joined.

Unlike in the Classic client where the hierarchy is defined by indenting data items, in the RoleTailored Client, the hierarchy is defined in each control, in this case the table control. The following steps show how to add the grouping of the customers by their salesperson.

1. Select the table control, right-click and then click Properties. The Table Properties window opens.

2. Click the Groups tab and then click Add. The Grouping and Sorting Properties window opens.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 34: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-34

3. Type or select the following: o Expression: =Fields!Salesperson_Purchaser_Code.Value

FIGURE 9.24 THE GROUPING AND SORTING PROPERTIES WINDOW

4. Leave the rest as it is, click OK and then click OK. Now, the layout looks as follows:

FIGURE 9.25 THE REPORT LAYOUT

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 35: Na2009 enus devi_09

Chapter 9: Reports

9-35

The table has six columns and five rows.

Table Row Remarks

First Table header

Second Group header of the group that is created in the Add Grouping section.

Third Group detail of the group that is created in the Add Grouping section.

Fourth Group footer of the group that is created in the Add Grouping section.

Fifth Table footer

Add Fields

The following steps show how to add fields to the report layout.

1. Drag the Salesperson_Purchaser_Code and Salesperson_Purchaser_Name fields from the DataSet Result to the first and second column of the second row of the table, respectively.

2. Repeat step 1 for the Customer__No__, Customer_Name, Customer_City and Customer__Phone_No__ fields from the DataSet Result to the appropriate columns of the third row of the table.

FIGURE 9.26 THE REPORT LAYOUT

3. Close Visual Studio and then click Yes when prompted to save the changes.

4. Click anywhere in the Report Designer and then click Yes to load the saved changes from Visual Studio.

NOTE: Remember to click Yes in steps 3 and 4. If this is not the case, the changes made to the report layout are not saved.

5. Compile, save and close the report.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 36: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-36

Run the Report in the RoleTailored Client

In the RoleTailored client, usually, a report is run from a page. However, to test the changes, run the report from the Run window. The following steps show how to run a report in the RoleTailored client.

1. On the Windows taskbar, click Start and then click Run. 2. In the Run window, type the following string:

dynamicsnav:////runreport?report=90000, where 90000 is the ID of the Customer by Salesperson report, and then click OK, to run the report.

The request page opens. This page enables users to enter filters for the data items or change the sorting of the data items. Users can also select to print or preview the report.

FIGURE 9.27 THE REQUEST PAGE

NOTE: Instead of tabs as in the request form, FastTabs that correspond to the data items are shown in the request page. In this case, the FastTab that corresponds to the Salesperson/Purchaser data item is shown and the FastTab that corresponds to the Customer data item is hidden, just as in the Classic client. The effect of setting the PrintOnlyIfDetail, ReqFilterFields and ReqFilterHeading property is the same as in the request form.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 37: Na2009 enus devi_09

Chapter 9: Reports

9-37

3. Click Preview.

FIGURE 9.28 THE PRINT PREVIEW WINDOW IN THE ROLETAILORED CLIENT

The report shows all salespersons and for each salesperson that has customers, all its customers.

NOTE: Several fields, such as the Name fields, are wide and require more space. These fields grow to the second line. The CanGrow property defines this behavior.

Print Header on Every Page

The customers for some salespersons extend to more than one page. However, on the second page, the report does not print any headings that indicate which salesperson that the customers are associated with. The following steps show how to achieve a similar result like when setting the PrintOnEveryPage property in the section to print a header on every page.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 38: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-38

2. Click View, Layout. 3. Open the Properties window for the table control and select Repeat

header rows on each page.

FIGURE 9.29 THE TABLE PROPERTIES WINDOW

4. Click OK to close the Properties window, close Visual Studio and

then click Yes when prompted to save the changes. 5. Click anywhere in the Report Designer and then click Yes to load the

saved changes from Visual Studio. 6. Compile, save and close the report. 7. Run the report to view the changes.

Print Subheader on Continuous Page

The following steps show how to achieve a similar result like when creating the TransHeader section to print a subheader for a continuous page.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Layout. 3. Open the Properties window for the table control.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 39: Na2009 enus devi_09

Chapter 9: Reports

9-39

4. Click the Groups tab, select the group and then click Edit. 5. Select Repeat group header and then click OK.

FIGURE 9.30 THE GROUPING AND SORTING PROPERTIES WINDOW

6. Click OK to close the Properties window, close Visual Studio and

then click Yes when prompted to save the changes. 7. Click anywhere in the Report Designer and then click Yes to load the

saved changes from Visual Studio. 8. Compile, save and close the report. 9. Run the report to view the changes.

Show New Record in a New Page

The following steps show how to achieve a similar result like when setting the NewPagePerRecord property to show a new record in a new page.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Layout. 3. Open the Properties window for the table control. 4. Click the Groups tab, select the group and then click Edit. 5. Select Page break at start and then click OK. 6. Click OK to close the Properties window, close Visual Studio and

then click Yes when prompted to save the changes.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 40: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-40

7. Click anywhere in the Report Designer and then click Yes to load the saved changes from Visual Studio.

8. Compile, save and close the report. 9. Run the report to view the changes.

The Request Options Designer The request form is displayed when the report is run in the Classic client and the request page is displayed when the report is run in the RoleTailored client. They have the same purpose which is to let the user provide additional input before previewing or printing the report.

The Request Options Form Designer

The request form contains some default elements that reflect the data items in a report. When a new report is created, a request form is automatically created for the report. In addition, custom options can be created on the Options tab in the request form. These options are designed by using the Request Options Form Designer which is accessed from the Report Designer. The following steps show how to open the Request Options Form Designer.

1. Open the Report Designer from the Object Designer. 2. In the Report Designer, click View, Request Form.

The Options tab is always displayed as the last tab of the request form, and is displayed only if there are controls in it. Only the Options tab of the request form can be customized. The rest of the tabs which correspond to the data items cannot be modified, although they can be hidden by sorting the data item (setting the DataItemTableView property) and clearing the ReqFilterFields property of the data item. Designing the Options tab is similar to designing any other form and usually requires coding in some triggers.

The Request Options Page Designer

The request page has the same purpose as the request form. It is displayed when the report is run in the RoleTailored client. When a new report is created, a request page is automatically created for the report. In addition, custom options can be created in the request page. These options are designed by using the Request Options Page Designer which is accessed from the Report Designer. The following steps show how to open the Request Options Page Designer.

1. Open the Report Designer from the Object Designer. 2. In the Report Designer, click View, Request Page.

The Request Options Page Designer is similar to the Page Designer. Here developers can add controls, such as FastTabs and fields to the request page. Controls that are created in the Request Options Page Designer are always displayed above the FastTabs that correspond to data items.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 41: Na2009 enus devi_09

Chapter 9: Reports

9-41

Demonstration: Design the Request Options Form The following demonstration shows how to design the request options form, add and remove tabs from it, add a control to the Options tab and use the control to affect the output of the report.

Add and Remove Tabs on the Request Form

Every data item has a tab on the request form, although it can be hidden by setting certain properties. Currently the Customer by Salesperson report has two data items, the Salesperson/Purchaser data item and the Customer data item. When it is run, the request form for this report shows one tab, the Salesperson tab.

The following steps show how to add and remove tabs on the request form.

1. Design report 90000, Customer by Salesperson from the Object Designer.

2. Open the Properties window for the Customer data item and clear the DataItemTableView property.

3. Close the Properties window, and compile, save and run the report in the Classic client.

The request form now shows two tabs, the Salesperson and the Customer tabs.

4. Close the request form. 5. Open the Properties window for the Customer data item and set the

DataItemTableView property to SORTING("No."). 6. Close the Properties window, and compile, save and run the report.

The request form now shows one tab, the Salesperson tab.

7. Close the request form. 8. Open the Properties window for the Customer data item and set the

ReqFilterFields property to "No." 9. Close the Properties window, and compile, save and run the report.

The request form now shows two tabs, the Salesperson and the Customer tabs.

10. Close the request form and close the report.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 42: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-42

Add a Check Box to the Options Tab

To add a data control to the Options tab of the request form, create a global variable for the control to be bound to. The user changes the value of the variable through the control. The following steps show how to create a global variable and a check box to the Options tab of the request form.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, C/AL Globals. The C/AL Globals window opens. 3. Type the following in the Variables tab:

Name DataType

ShowDetails Boolean

4. Close the C/AL Globals window. 5. Click View, Request Form. The Request Options Form Designer

opens. 6. Add a check box and label to the form (use the Add Label option). 7. Open the Properties window for the check box and set the following

properties: o Caption: Show Details (This also changes the Caption of the

attached label.) o SourceExpr: ShowDetails

8. Close the Properties window and close the Request Options Form

Designer.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 43: Na2009 enus devi_09

Chapter 9: Reports

9-43

9. Compile, save, and close the report. 10. Run the report in the Classic client.

FIGURE 9.31 THE REQUEST FORM

The request form now shows three tabs, the Salesperson, the Customer and the Options tabs. The Options tab has a check box labeled Show Details in it.

Set the Request Form to Save Variable Values

Every time that the report is run, the ShowDetails variable is set to its default value which is FALSE. The following steps show how to set the request form to save its variable value so that the value is saved in the ZUP file and is remembered.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Request Form. The Request Options Form Designer opens.

3. Open the Properties window for the request form and set the SaveValues property to Yes.

4. Close the Properties window and close the Request Options Form Designer.

5. Compile, save, and close the report. 6. Run the report in the Classic client. 7. Select the Show Details check box and preview the report. Then,

close the report preview and rerun the report.

The request form remembers the ShowDetails variable value from the previous run.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 44: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-44

Skip Sections in a Report

Use the value of the check box added in the request form to display or not display a section in the report. The following steps show how to conditionally show the Body section of the Customer data item, depending on the value of the Show Details check box in the request form.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Sections to open the Section Designer. 3. Click the gray bar for the Cust. Ledger Entry Body section. This

selects that section. 4. Click View, C/AL Code or press F9 to open the C/AL Editor. 5. In the OnPreSection trigger, type the following:

CurrReport.SHOWOUTPUT(ShowDetails);

6. Close the C/AL Editor and close the Section Designer. 7. Compile, save and close the report. 8. Run the report in the Classic client, select the Show Details check

box in the Options tab of the request form and then click the Preview button.

9. Close the report preview, rerun the report, and this time, clear the Show Details check box and then click the Preview button and view the changes.

Demonstration: Design the Request Options Page The following demonstration shows how to design the request options page, add and remove FastTabs from it, add a control to the Options FastTab and use the control to affect the output of the report.

Add and Remove FastTabs on the Request Page

Every data item has a FastTab on the request page. It behaves the same as tabs in the request form. It can be hidden or shown by setting exactly the same properties as in the request form.

Create Options FastTab and Add a Check Box

The following steps show how to create a check box to the Options FastTab of the request page.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 45: Na2009 enus devi_09

Chapter 9: Reports

9-45

2. Click View, Request Page. The Request Options Page Designer opens. It resembles the Page Designer.

3. Type the following on the first line of the Page Designer:

Caption Type SubType Request Page Container ContentArea

4. Go to the next blank line. The page elements automatically indent. 5. Type the following:

Caption Type SubType

Options Group Group

This creates the Options FastTab.

6. Type the following on the next line and ensure that it is indented under the Options FastTab:

Caption Type SourceExpr

Show Details Field ShowDetails

FIGURE 9.32 THE REQUEST OPTIONS PAGE DESIGNER

7. Close the Request Options Page Designer.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 46: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-46

8. Compile, save, and close the report. 9. Run the report in the RoleTailored client.

FIGURE 9.33 THE REQUEST PAGE

The request page now shows three FastTabs, the Options, the Salesperson, and the Customer FastTabs. The Options FastTab has a check box labeled Show Details in it.

Skip Lines in a Report

Use the value of the check box added in the request page to display or not display a section in the report. The following steps show how to conditionally show the detail of the Customer, depending on the value of the Show Details check box in the request page.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Sections to open the Section Designer. 3. Add a text box in the Body section of the customer data item, and set

the following properties: o Visible: No o SourceExpr: ShowDetails

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 47: Na2009 enus devi_09

Chapter 9: Reports

9-47

4. Close the Section Designer.

NOTE: The purpose of steps 1 to 3 is to add ShowDetail as one of the fields in the dataset result in Visual Studio. This is a hidden field which is added to achieve a similar result as CurrReport.SHOWOUTPUT, because section triggers are not supported in the RoleTailored Client.

5. Click View, Layout. 6. Select the third row (the Detail row) and set the following property:

o Visibility, Hidden: =IIF(Fields!ShowDetails.Value,false,true)

7. Close Visual Studio and then click Yes when prompted to save the changes.

8. Click anywhere in the Report Designer and then click Yes to load the saved changes from Visual Studio.

9. Compile, save and close the report. 10. Run the report in the RoleTailored client, select the Show Details

check box in the Options FastTab of the request page and then click the Preview button.

11. Close the report preview, rerun the report, and this time, clear the Show Details check box and then click the Preview button and view the changes.

Grouping Within a Classic Report Typically, a report must print subtotals to separate groups of records based on certain fields within the records. In Microsoft Dynamics NAV, developers must indicate which fields to be monitored for these events in the report. The report monitors the fields, and when they change to a new value, special sections can be printed on the report. These special sections are not printed unless the report has grouping on fields.

Grouping is not needed if indentation can be used to link and filter the data items. But grouping must be used if the field that is to be grouped on is not related to another table.

The most common use for grouping is to subtotal a report by Date. Date fields are not related to a table, but signify important groups within the table. For example, developers may want to examine Customer Ledger Entries by Customer and for each Customer, by Date. They can group the entries by Customer by using indentation. But they still have to group on one field which is the Date field.

NOTE: In most cases, it is easier to use indentation instead of grouping. Grouping on more than one field is sometimes difficult and requires writing some code. Indentation is a more natural way to use in the Report Designer.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 48: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-48

The GroupTotalFields Property

The GroupTotalFields property is the key for grouping. It is used to specify fields to be grouped on by the report. It enables printing special sections which usually are used to show subtotals in the report. Although, this property has nothing to do with totals or indentation, the name of the property is somewhat misleading.

To correctly use this field, developers must be aware of the following:

• The fields specified in this property must also be in the key that is specified in the DataItemTableView property.

• If the DataItemTableView does not have the correct key, the fields specified in the GroupTotalFields property are ignored by the report.

• Special sections must be created in the Section Designer. Grouping causes these sections to be printed at the correct time.

The GroupHeader and GroupFooter Sections

Grouping enables developers to print the special sections which are the GroupHeader and the GroupFooter sections in the report. As their names imply, these groups are printed before a group starts and after a group is finished. The GroupHeader section prints after any Header sections and before any Body sections for the current group, or right after the previous group's GroupFooter section. The GroupFooter section prints after the last Body section for the current group and before the GroupHeader of the next group, or before the Footer section.

Demonstration: Create Grouping For The Classic Report The following demonstration shows how to create grouping in the report by using table keys and GroupTotalFields property and also indentation.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 49: Na2009 enus devi_09

Chapter 9: Reports

9-49

Prepare the Cust. Ledger Entry Table

Before getting started with the report, add a key to the Cust. Ledger Entry table:

1. Design table 21, Cust. Ledger Entry, from the Object Designer. 2. Click View, Keys and add Posting Date to the list of keys.

FIGURE 9.34 THE KEYS WINDOW

3. Close the Keys window and compile, save, and close the table.

Create a New Report

The following steps show how to create a new report that uses grouping.

1. In the Object Designer's Report list, click the New button. The New Report window opens. In this demonstration, do not use the Report Wizard.

2. Select Create a Blank Report and then click the OK button. The Report Designer opens.

3. Click the first empty line in the Report Designer, and type or select the number or name of table 21, Cust. Ledger Entry.

4. Open the Properties window for the Cust. Ledger Entry data item and set the following properties: o DataItemTableView: SORTING(Posting Date) o GroupTotalFields: Posting Date

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 50: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-50

NOTE: The GroupHeader section will not be printed without the correct setting, and the correct sorting and key in the DataItemTableView property.

5. Close the Properties window. 6. Click View, Sections to open the Section Designer. 7. Insert a Header and a GroupHeader section for the Cust. Ledger

Entry data item. 8. In the Body section, add the Posting Date, Customer No.,

Document Type,Document No., Description and Amount (LCY) fields from the Cust. Ledger Entry table. Move the labels to the Header section of the Cust. Ledger Entry data item.

9. Select the Posting Date text box, and drag it to the GroupHeader section.

FIGURE 9.35 THE SECTION DESIGNER

10. Compile and save the report with the ID 90001 and the name

Customer Detail, and close the report. 11. Run and preview the report in the Classic client.

The report shows the Customer's ledger entries grouped by the Posting Date.

Use Grouping Together With Indentation

Change this report so that it groups the Customer Ledger Entries, first by Customer then by Posting Date. Instead of adding Customer No. to the GroupTotalFields property, use indentation with another data item. The following steps show how to use grouping together with indentation.

1. Design report 90001, Customer Detail, from the Object Designer. 2. Press F3 to insert a line above the Cust. Ledger Entry data item. 3. Select the Customer table for this new data item. 4. Indent the Cust. Ledger Entry data item under the Customer data

item.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 51: Na2009 enus devi_09

Chapter 9: Reports

9-51

5. Open the Properties window for the Cust. Ledger Entry data item and set the following properties: o DataItemTableView: SORTING(Customer No.,Posting Date) o DataItemLink: Customer No.=FIELD(No.)

6. Close the Properties window, and then click View, Sections to open the Section Designer.

7. Insert a Header section for the Customer data item. 8. In the Body section of the Customer data item, add the No., Name,

City, and Phone No. fields from the Customer table. Move the labels to the Header section of the Customer data item.

9. Move the controls on the Cust. Ledger Entry sections to the right side to show the indentation. To do this, select all the controls on a section and move them to the right side. The > symbol in the gray bar of the sections of the Cust. Ledger Entry data item signifies that this data item is indented.

FIGURE 9.36 THE SECTION DESIGNER

10. Close the Section Designer and compile, save, and close the report. 11. Run and preview the report in the Classic client.

Totaling in a Report A report is usually designed to give the user summary information about what is in the database. This usually requires adding one or more fields that are displayed or read by the report, and then displaying the sum. This process is known as totaling the report.

Microsoft Dynamics NAV uses subtotals and grand totals. Subtotals are shown after a logical grouping of records. Grand totals are shown at the end of the report. Subtotals sum the group and grand totals sum the whole report, meaning, grand totals sum all subtotals.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 52: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-52

The TotalFields Property

The TotalFields property is used to specify which fields that developers want to sum. The report tracks the totals of those fields specified in this property. This property does not tell the report to display the totals.

How to Display the Totals

To display the total amounts for the fields specified in the TotalFields property, developers must to do the following:

• Create a section to display the Totals. The report only displays total amounts on several types of sections: Footer, GroupFooter, TransFooter, or TransHeader.

• Create controls with the SourceExpr property set to the fields in that section. Because the fields are displayed on a footer type section, the report shows the total amounts of the fields instead of the current value of the fields.

Demonstration: Create Totals For The Classic Report The following demonstration shows how to create subtotal and grand total for one or more data items in the report.

Add Subtotal and Grand Total

The following steps show how to add the subtotal and the grand total for the Cust. Ledger Entry data item.

1. Design report 90001, Customer Detail, from the Object Designer. 2. Open the Properties window for the Cust. Ledger Entry data item

and set the TotalFields property to Amount (LCY).

This tells the report to calculate totals for the Amount (LCY) field as the Cust. Ledger Entry data item is iterated.

3. Close the Properties window, and then click View, Sections. 4. Insert a GroupFooter section and a Footer section for the Cust.

Ledger Entry data item.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 53: Na2009 enus devi_09

Chapter 9: Reports

9-53

5. In the GroupFooter section and the Footer section of the Cust. Ledger Entry data item, add the Amount (LCY) field from the Cust. Ledger Entry table.

6. Delete the labels and align the text boxes under the Amount (LCY) text box in the Body section.

FIGURE 9.37 THE SECTION DESIGNER

7. Close the Section Designer and compile, save, and close the report. 8. Run and then preview the report in the Classic client.

Add the Grand Total with More than One Data Item

The following steps show how to add the grand total for the Customer data item.

1. Design report 90001, Customer Detail, from the Object Designer. 2. Click the Customer data item and then click View, C/AL Code or

press F9 to open the C/AL Editor. 3. In the OnPreDataItem trigger, type the following:

CurrReport.CREATETOTALS("Cust. Ledger Entry"."Amount (LCY)");

4. Close the C/AL Editor and then click View, Sections to open the Section Designer.

5. Insert a Footer section for the Customer data item. 6. In the footer section, established in step 5, manually add a text box. 7. Open the Properties window for the text box and set the SourceExpr

property of the text box to "Cust. Ledger Entry"."Amount (LCY)". 8. Close the Properties window and close the Section Designer.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 54: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-54

9. Compile, save, and close the report. 10. Run and preview the report in the Classic client

FIGURE 9.38 THE REPORT IN THE CLASSIC CLIENT

Demonstration: Create Grouping and Totals For The RoleTailored Report

The following demonstration shows how to create a grouping, the subtotal and the grand total for the Customer Detail report to be run in the RoleTailored client.

Prepare the Layout

The following steps show how to design the report layout in Microsoft Visual Studio Report Designer.

1. Design report 90001, Customer Detail, from the Object Designer. 2. Click View, Layout. 3. Drag a Table control from the toolbox to the report layout.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 55: Na2009 enus devi_09

Chapter 9: Reports

9-55

4. Click one of the columns, right-click and then click Insert Column to the Right.

5. Repeat step 4 two times to add two more columns.

FIGURE 9.39 THE TABLE WITH SIX COLUMNS

Add Column Headers

To add column headers to the report layout, drag the Customer__No__Caption, Customer_NameCaption, Customer_CityCaption and Customer__Phone_No__Caption fields from the DataSet Result to the first to fourth columns of the first row of the table.

FIGURE 9.40 THE TABLE WITH COLUMN HEADERS

Add Groupings

The following steps show how to add the grouping of the records, first by Customer, and then by Posting Date.

1. Select the table control, right-click and then click Properties. The Table Properties window opens.

2. Click the Groups tab and then click Add. The Grouping and Sorting Properties window opens.

3. Type or select the following: o Expression: =Fields!Customer__No__.Value

4. Leave the rest as it is, and then click OK. 5. Click Add again and type the following:

o Expression: =Fields!Cust__Ledger_Entry__Posting_Date_.Value

o Parent Group: =Fields!Customer__No__.Value

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 56: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-56

6. Leave the rest as it is, click OK, and then click OK.

FIGURE 9.41 THE TABLE WITH SIX COLUMNS AND SEVEN ROWS

Add Subheaders and Fields

The following steps show how to add fields and subheaders to the report layout.

1. Drag the Customer__No__, Customer_Name, Customer_City and Customer__Phone_No__ fields from the DataSet Result to the appropriate columns of the second row of the table. This creates the header.

2. Drag the Cust__Ledger_Entry__Posting_Date_Caption and the Cust__Ledger_Entry__Posting_Date_ fields from the DataSet Result to the first and second columns of the third row of the table. This creates the subheaders.

3. Drag the Cust__Ledger_Entry__Document_Type_Caption, Cust__Ledger_Entry__Document_No__Caption, Cust__Ledger_Entry_DescriptionCaption and Cust__Ledger_Entry__Amount__LCY__Caption fields from the DataSet Result to the third to sixth columns of the third row of the table. This creates the subheaders.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 57: Na2009 enus devi_09

Chapter 9: Reports

9-57

4. Drag the Cust__Ledger_Entry__Document_Type_, Cust__Ledger_Entry__Document_No__, Cust__Ledger_Entry_Description and Cust__Ledger_Entry__Amount__LCY__ fields from the DataSet Result to the third to sixth columns of the fourth row of the table. This creates the detail.

FIGURE 9.42 THE TABLE WITH FIELDS

Add Totals and Set Format Property

The following steps show how to add totals to the report layout.

1. Drag the Cust__Ledger_Entry__Amount__LCY__ field from the DataSet Result to the sixth column of the fifth row of the table. Notice that Sum is selected as the aggregate function. This creates the total for every posting date.

2. Drag the Cust__Ledger_Entry__Amount__LCY__ field from the DataSet Result to the sixth column of the sixth row of the table. This creates the total for every customer.

3. Drag the Cust__Ledger_Entry__Amount__LCY__ field from the DataSet Result to the sixth column of the seventh row of the table. This creates the total for the whole report.

4. Select the Amount LCY text box (the sixth column of the fourth row) and set the following property: o Format:

=Fields!Cust__Ledger_Entry__Amount__LCY__Format.Value

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 58: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-58

5. Repeat step 4 for all the text boxes that represent the Amount LCY and the sum of Amount LCY.

FIGURE 9.43 THE TABLE WITH TOTALS

6. Close Visual Studio and then click Yes when prompted to save the changes.

7. Click anywhere in the Report Designer and then click Yes to load the saved changes from Visual Studio.

8. Compile, save and close the report. 9. Run and preview the report in the RoleTailored client.

FIGURE 9.44 THE REPORT IN THE ROLETAILORED CLIENT

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 59: Na2009 enus devi_09

Chapter 9: Reports

9-59

Demonstration: Add Some Advanced Features The following demonstration shows how to add advanced features to the report including the use of FlowFilters, and features a specific report in the RoleTailored client such as interactive sorting, hide/collapse an item, and charts.

Use FlowFilters

The following steps show how to add the ability to filter the report that uses the Date Filter field in the Customer table:

1. Design report 90001, Customer Detail, from the Object Designer. 2. Open the Properties window for the Customer data item and set the

ReqFilterFields property to include the Date Filter field.

FIGURE 9.45 THE CUSTOMER PROPERTIES WINDOW

3. Open the Properties window for the Cust. Ledger Entry data item

and set the DataItemLink property to Customer No.=FIELD(No.),Posting Date=FIELD(Date Filter).

FIGURE 9.46 THE DATAITEM LINK WINDOW

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 60: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-60

4. Close the Properties window and then compile, save and close the report.

5. Run the report. 6. In the Customer tab of the request form, type the range

01/01/01..12/31/01 in the Filter column for the Date Filter field, and then click the Preview button.

Check whether there are any records outside the range that is set.

Add Interactive Sorting

The following steps show how to add interactive sortings to the Customer by Salesperson report.

In the Object Designer's Report list:

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Layout. 3. Select the text box in the first column of the table header row

(Salesperson_Purchaser_CodeCaption) and set the following properties: o UserSort, SortExpression:

=Fields!Salesperson_Purchaser_Code.Value o UserSort, SortExpressionScope: table1_Group1

FIGURE 9.47 THE USERSORT PROPERTIES

4. Repeat step 3 for the rest of the text boxes in the table header row

with their respective SortExpression. However, for text boxes that belong to customer table, leave the SortExpressionScope property blank.

5. Close Visual Studio and then click Yes when prompted to save the changes.

6. Click anywhere in the Report Designer and then click Yes to load the saved changes from Visual Studio.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 61: Na2009 enus devi_09

Chapter 9: Reports

9-61

7. Compile, save and close the report. 8. Run the report in the RoleTailored client to view the changes.

FIGURE 9.48 THE REPORT WITH INTERACTIVE SORTING

Add Hide/Collapse Item

The following steps show how to add the hide/collapse feature to the Customer by Salesperson report.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Layout. 3. Select the first group detail row (third row) and set the following

property: o Visibility, ToggleItem: Salesperson_Purchaser_Code

4. Select the text box in the first column, second row

(Salesperson_Purchaser_Code) and set the following property: o InitialToggleState: Expanded

5. Close Visual Studio and then click Yes when prompted to save the

changes. 6. Click anywhere in the Report Designer and then click Yes to load the

saved changes from Visual Studio.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 62: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-62

7. Compile, save and close the report. 8. Run the report in the RoleTailored client to view the changes.

FIGURE 9.49 THE REPORT WITH HIDE/COLLAPSE ITEM

Add a Chart

Charts are a graphical representation of data, and help present information in a summarized, yet concise manner. In the Classic client, creating charts in a report is a cumbersome effort and requires lots of consideration and programming. In the RoleTailored client, this is made easier and possible with minimal effort.

The following steps show how to add a chart to the Customer by Salesperson report to represent how many customers, a salesperson has.

1. Design report 90000, Customer by Salesperson, from the Object Designer.

2. Click View, Layout. 3. Drag a Chart control from the toolbox to the report layout. 4. Select the chart control, right-click and then click Properties. The

Chart Properties window opens.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 63: Na2009 enus devi_09

Chapter 9: Reports

9-63

5. At the General tab, set the following: o Title: Customer by Salesperson o Chart Type: Pie

FIGURE 9.50 THE CHART PROPERTIES WINDOW

6. Click the Data tab and set the following:

o Dataset name: DataSet_Result

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 64: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-64

7. Click the Add button at the Values section. The Edit Chart Values window opens.

8. At the Values tab, clear the Series label and set the following: o Value: =Count(Fields!Customer__No__.Value)

FIGURE 9.51 THE EDIT CHART VALUES WINDOW

9. Click OK. 10. Click the Add button at the Series groups section. The Grouping

and Sorting Properties window opens.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 65: Na2009 enus devi_09

Chapter 9: Reports

9-65

11. At the General tab, set the following: o Expression: =Fields!Salesperson_Purchaser_Code.Value o Label: =Fields!Salesperson_Purchaser_Name.Value

FIGURE 9.52 THE GROUPING AND SORTING PROPERTIES WINDOW

12. Click OK. 13. Click OK to close the Chart Properties window. 14. Close Visual Studio and then click Yes when prompted to save the

changes. 15. Click anywhere in the Report Designer and then click Yes to load the

saved changes from Visual Studio.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 66: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-66

16. Compile, save and close the report. 17. Run the report in the RoleTailored client to view the changes.

FIGURE 9.53 THE REPORT WITH A CHART

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 67: Na2009 enus devi_09

Chapter 9: Reports

9-67

Lab 9.1 - Create a Basic Report The following lab tests the basic knowledge on how to create a report for both the Classic and the RoleTailored client.

Scenario

Simon is a developer working for CRONUS International Ltd. CRONUS International has decided to start selling Microsoft Dynamics NAV training courses as its business.

Simon has already created a Course table to record course information. Now, Simon must create a report to list all the courses available. The report must be able to run in both the Classic and the RoleTailored client.

Challenge Yourself!

1. Create a report that has the following requirements: a. Prints all the course information. b. Filters by the course type.

2. Enable this report to be run in the RoleTailored client together with

advanced features: a. Interactive sorting. b. A bar chart that represents courses and the cost of investment

(price) for each course.

Step by Step

Create a new report using a wizard.

1. In the Object Designer's Report List, click the New button. 2. Type Course in the Table field. 3. Select Create a Report using a wizard, select Tabular-Type

Report Wizard and then click OK. 4. Select all the fields by clicking the Double Right Arrow button, and

then click Next. 5. Select No, I don't want a special sorting of my data and then click

Next. 6. Click Finish.

Add a filter.

1. Open the Properties window for the Course data item. 2. Set the ReqFilterFields property to Type. 3. Close the Properties window.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 68: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-68

Enable the report to be run in the RoleTailored client.

1. Click View, Layout. 2. Drag a Table control from the toolbox to the report layout. 3. Click one of the columns, right-click and then click Insert Column

to the Right. 4. Repeat step 3 five times to add five more columns. 5. Drag the Course_CodeCaption, Course_NameCaption,

Course_DescriptionCaption, Course_TypeCaption, Course_DurationCaption, Course_PriceCaption, Course_ActiveCaption, Course_DifficultyCaption and Course_Passing_Rate_Caption fields from the DataSet Result to the appropriate columns of the first row of the table.

6. Drag the Course_Code, Course_Name, Course_Description, Course_Type, Course_Duration, Course_Price, Course_Active, Course_Difficulty and Course_Passing_Rate_ fields from the DataSet Result to the appropriate columns of the second row of the table.

Add Interactive Sorting.

1. Select the text box in the first column of the table header row (Course_CodeCaption) and set the following properties: o UserSort, SortExpression: =Fields!Course_Code.Value

2. Repeat step 1 for the rest of the text boxes in the table header row

with their respective SortExpression.

Add a Chart.

1. Drag a Chart control from the toolbox to the report layout. 2. Select the chart control, right-click and then click Properties. 3. At the General tab, set the following:

o Title: Course Price o Chart Type: Bar

4. Click the Data tab and set the following:

o Dataset name: DataSet_Result

5. Click the Add button at the Values section. 6. At the Values tab, clear the Series label and set the following:

o Value: =(Fields!Course_Price.Value)

7. Click OK. 8. Click the Add button at the Series groups section.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 69: Na2009 enus devi_09

Chapter 9: Reports

9-69

9. At the General tab, set the following: o Expression: =Fields!Course_Code.Value o Label: =Fields!Course_Name.Value

10. Click OK. 11. Click OK to close the Chart Properties window. 12. Close Visual Studio and then click Yes when prompted to save the

changes. 13. Click anywhere in the Report Designer and then click Yes to load the

saved changes from Visual Studio. 14. Compile and save the report as 90011, Course List and then close

the report.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 70: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-70

Summary An organization's ability to collect dependable, timely business intelligence is fundamental to its health, and reports are a way to obtain that intelligence. A C/SIDE developer is expected to create robust reports on demand. This involves an understanding not only of the mechanics of report creation, but of business needs.

Reports print information from a database and they can structure and summarize information. Reports can be used to print documents such as invoices, and they can also be used to process data without printing anything.

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 addition, developing reports for the RoleTailored client requires additional design consideration.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 71: Na2009 enus devi_09

Chapter 9: Reports

9-71

Test Your Knowledge 1. True or False: All reports must print at least one page.

2. List the names of the three Designers used with reports, and describe their function.

3. How many times does a Header section print on a report for an indented data item (assume PrintOnEvery page is turned off and there is data in the table)? What if the data item is not indented?

4. What data item property can be used to remove the Data Items tab on the request form (assume there are no request filter fields set)?

5. What two properties of a data item must be set to print a subtotal of a field on a group footer section?

6. When does a TransHeader section print for a data item?

7. What property can be set to start a new page every time that a record is read?

8. What two properties can be used to print a footer at the bottom of every page?

9. What C/AL code can be written that most closely resembles a report that has two data items, with the second indented?

10. What property can be used to filter an indented data item based on fields in the unindented data item above it?

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

Page 72: Na2009 enus devi_09

C/SIDE Introduction in Microsoft Dynamics® NAV 2009

9-72

Quick Interaction: Lessons Learned Take a moment and write down three key points you have learned from this chapter

1.

2.

3.

Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement