Microsoft Dynamics NAV 2013 - 80433 - Reporting

March 12, 2017 | Author: Ramin Marghi | Category: N/A
Share Embed Donate


Short Description

Download Microsoft Dynamics NAV 2013 - 80433 - Reporting...

Description

Course 80433: Reporting in Microsoft Dynamics® NAV 2013

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

This courseware is provided “as-is”. Information and views expressed in this courseware, including URL and other Internet Web site references, may change without notice. Unless otherwise noted, the examples depicted herein are provided for illustration only and are fictitious. No real association or connection is intended or should be inferred. This courseware does not provide you with any legal rights to any intellectual property in any Microsoft product. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this courseware may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means or for any purpose, without the express written permission of Microsoft Corporation. Copyright © 2012 Microsoft Corporation. All rights reserved. Microsoft®, Microsoft Dynamics®, Microsoft® PowerPoint®, Microsoft® SQL Server® data management software and Microsoft Dynamics® NAV are trademarks of the Microsoft group of companies. All other trademarks are property of their respective owners.

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

Table of Contents Introduction Microsoft Dynamics Courseware Overview………………………………………………..…………….….....0-3 Student Objectives………………………………………………………………………………………..…………….….0-4

Module 1: CREATING REPORTS Lesson 1: Prerequisites .................................................................................................................................1-4 Lesson 2: Anatomy of Reports...................................................................................................................1-6 Lesson 3: Creating the Dataset .............................................................................................................. 1-13 Lesson 4: Creating the Layout ................................................................................................................ 1-16 Lesson 5: Dataset Patterns ....................................................................................................................... 1-30 Lesson 6: Report Properties ..................................................................................................................... 1-38 Lesson 7: Building the Request Page ................................................................................................... 1-42 Lesson 8: Sorting and Filtering ............................................................................................................... 1-45 Lab 1.1: Creating a Table Report ........................................................................................................... 1-52 Lab 1.2: Creating a Matrix Report ......................................................................................................... 1-66 Lab 1.3: Adding a Chart ............................................................................................................................ 1-71 Lab 1.4: Using a Gauge ............................................................................................................................. 1-75

Module 2: INTERACTIVE FEATURES Lesson 1: Working with Headers and Footers .....................................................................................2-3 Lesson 2: Grouping ..................................................................................................................................... 2-16 Lesson 3: Using Images in a Report ..................................................................................................... 2-45 Lesson 4: Print Preview and Print Layout ........................................................................................... 2-51 Lesson 5: Working with Visibility Options ......................................................................................... 2-52 Lesson 6: Interactive Sorting ................................................................................................................... 2-55 Lesson 7: Working with Document Maps .......................................................................................... 2-62 1

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

Reporting in Microsoft Dynamics® NAV 2013 Lesson 8: Creating a Multi Column Report ....................................................................................... 2-65 Lesson 9: Formatting Reports and Report Items ............................................................................. 2-67 Lab 2.1: Adding Visibility Options ......................................................................................................... 2-77 Lab 2.2: Adding Interactive Sorting ...................................................................................................... 2-83 Lab 2.3: Adding a Document Map........................................................................................................ 2-86 Lab 2.4: Adding Pictures to a Report ................................................................................................... 2-88

Module 3: ADDING CODE TO A REPORT Lesson 1: Using Variables and C/AL Code in a Report .....................................................................3-3 Lesson 2: Working with Report Expressions ...................................................................................... 3-11 Lesson 3: Understanding and Using Simple and Complex Expressions ................................. 3-20 Lesson 4: Expression Examples ............................................................................................................... 3-30 Lesson 5: Anatomy of the Sales Invoice Report ............................................................................... 3-46 Lab 3.1: Adding Conditional Formatting to a Report – Part I ................................................... 3-65 Lab 3.2: Adding Conditional Formatting to a Report – Part II ................................................... 3-69 Lab 3.3: Cleaning Up the Report and Using the Company Logo from the Database ....... 3-77

Module 4: DESIGN CONSIDERATIONS Lesson 1: Report Patterns and Recipes ..................................................................................................4-2 Lesson 2: Report Rendering Considerations ..................................................................................... 4-25 Lesson 3: Pagination .................................................................................................................................. 4-29 Lesson 4: Useful Information .................................................................................................................. 4-33 Lab 4.1: Creating Green Bar Reports .................................................................................................... 4-52 Lab 4.2: Creating a Top X Report .......................................................................................................... 4-56

2

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

Table of Contents Module 5: RUNNING REPORTS Lesson 1: The ReportViewer Control .......................................................................................................5-2 Lesson 2: Run a Report in Microsoft Dynamics NAV ........................................................................5-5 Lesson 3: Hyperlinks to Reports ............................................................................................................. 5-12 Lesson 4: Run a Report from the SharePoint Site ........................................................................... 5-24 Lesson 5: Hyperlinks in a Report ........................................................................................................... 5-26 Lesson 6: Run a Stand-Alone Report in Visual Studio ................................................................... 5-33 Lesson 7: Interesting Links ....................................................................................................................... 5-39 Lab 5.1: Add a Report to the RoleTailored Client ........................................................................... 5-42 Lab 5.2: Call a Report from a Web Service ........................................................................................ 5-47

Module 6: UPGRADE REPORTS Lesson 1: How to Upgrade a Report to Microsoft Dynamics NAV 2013 .................................. 6-2 Lesson 2: Optimize the Dataset for the New Report Dataset Designer .................................... 6-7 Lesson 3: The Windows Page File ......................................................................................................... 6-10 Lesson 4: Optimize the Layout for RDLC 2008 ................................................................................ 6-12 Lesson 5: Determining which Reports to Upgrade ........................................................................ 6-18 Lab 6.1: Redesigning a Customer List Report ................................................................................... 6-21 Lab 6.2: Redesigning a Customer - Order Summary Report ...................................................... 6-27

3

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

Reporting in Microsoft Dynamics® NAV 2013 We created this additional Table of Contents to assist you in quickly finding out the areas that are new and, or changed from the Microsoft Dynamics NAV earlier version for this course. These areas are identified with this icon throughout the training material.

Module 1: CREATING REPORTS Lesson 5: Dataset Patterns ....................................................................................................................... 1-30

Module 2: INTERACTIVE FEATURES Topic 3: Table Header and Footer ...........................................................................................................2-8 Topic 1: Group Header and Footer....................................................................................................... 2-16 Demonstration: Add a Parent or Child Row or Column Group to a Tablix ........................ 2-18 Demonstration: Add an Adjacent Row or Column Group to a Tablix .................................. 2-19 Demonstration: Edit a Row or Column Group in a Tablix Data Region............................... 2-20 Demonstration: Delete a Group from a Tablix .............................................................................. 2-21 Topic 2: Using a Stepped Report ........................................................................................................... 2-22 Demonstration: Create a Sstepped Rreport.................................................................................... 2-22 Demonstration: Adding Interactive Sorting - No Grouping .................................................... 2-57 Demonstration: Adding Interactive Sorting - Grouping (Group Header Field) ................ 2-57 Demonstration: Adding Interactive Sorting - Grouping (Detail Field) ................................. 2-60 Lesson 8: Creating a Multi Column Report ....................................................................................... 2-65 Lesson 9: Formatting Reports and Report Items ............................................................................. 2-67

Module 3: ADDING CODE TO A REPORT Topic 1: Understanding Display Text for Expressions .................................................................... 3-20

Module 4: DESIGN CONSIDERATIONS Topic 2: Dashboards ......................................................................................................................................4-9 Topic 4: SAVEASEXCEL, SAVEASPDF and SAVEASWORD............................................................. 4-27

4

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

Table of Contents Module 5: RUNNING REPORTS Lesson 1: The ReportViewer Control .......................................................................................................5-2 Lesson 4: Run a Report from the SharePoint Site ........................................................................... 5-24 Demonstration: Creating a Link from a Report to a Report ..................................................... 5-30 Lesson 6: Run a Stand-Alone Report in Visual Studio ................................................................... 5-33 Topic 1: Run an Offline Report ............................................................................................................... 5-33 Lesson 7: Interesting Links ....................................................................................................................... 5-39

5

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

Reporting in Microsoft Dynamics® NAV 2013

6

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

MODULE 1: CREATING REPORTS Module Overview Microsoft Dynamics® NAV 2013 is one of the most innovative releases in the product’s history. This module overview describes the main differences between Microsoft Dynamics NAV 2013 and all previous versions. It also describes the competitive advantages of the Microsoft Dynamics NAV 2013 release. Like the previous version, Microsoft Dynamics NAV 2013 is built on a three-tier architecture model. The introduction of Microsoft Dynamics NAV 2013 means the end of the two-tier architecture. •

The RoleTailored client is the client tier.



In addition, Microsoft Dynamics NAV 2013 also supports additional client types, including web service clients, Microsoft Dynamics NAV Web client, a SharePoint client through Microsoft Dynamics NAV Portal Framework, and a NAS services client for programmatic access.



Microsoft Dynamics NAV Server is the middle or server tier, managing all business logic and communication.



SQL Server, augmented by Microsoft Dynamics NAV 2013 database components, is the data tier.

More information on the architecture is covered in the course Installation and Configuration in Microsoft Dynamics NAV 2013. Although the two-tier architecture has proven its value through the years, the three-tier architecture offers many competitive advantages. Openness The new architecture allows objects (pages and codeunits) to be exposed as web services. This means that the object (and its business logic) is made available as a .NET assembly and can be called from any external application speaking SOAP (Simple Object Access Protocol). Multiple Clients This technological innovation had another impact. By making the business logic available on a separate tier and as a .NET assembly, Microsoft opened the gates for client applications other than the Classic client. It is now possible to develop applications on multiple software (WinForms, Web applications) or hardware platforms (computer, mobile devices, and so on).

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

1-1

Reporting in Microsoft Dynamics® NAV 2013 The following can be considered Microsoft Dynamics NAV clients because they interact with the Microsoft Dynamics NAV database through Microsoft Dynamics NAV Server. •

RoleTailored client



Microsoft Dynamics NAV Portal Framework



Microsoft Dynamics NAV web client



SOAP web service client



OData web service client



NAS services client

All of the clients mentioned here also share the same business logic. Enhanced Productivity through the RoleTailored Interface The interface of the Dynamics NAV is role tailored, which means it is built around the way users work and the tasks they execute in their daily job. In the RoleTailored client, the interface is optimized for employees to fulfill their jobs. It offers functions that are relevant for a specific task. Instead of having to search for a specific function in the menus, users have instant access to all the relevant features they need, which results in higher productivity. Although the new architecture made the product more open, it also implied certain challenges. Since the business logic is no longer executed on the client, some of the functionalities required (major) design changes. In addition, the new solutions needed to support multiple display targets in an easy way. The two areas severely impacted by this architecture are data presentation and reporting. Microsoft has solved these challenges by introducing pages and by further integrating with other Microsoft products, such as Microsoft Visual Studio® and the ReportViewer control that supports a local processing mode that allows you to run Client Report Definition files (RDLC). Pages are the RoleTailored client; the equivalent for the Classic form object. Unlike classic forms, pages have no fixed width and height, but resize automatically in the function of the display target. The reporting solution in Microsoft Dynamics NAV 2013 is taking advantage of the enhanced functionalities of RDLC 2008. This course describes the reporting solution.

1-2

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

Module 1: Creating Reports Objectives The objectives are: •

Describe the roles of reports and know the anatomy of a report.



Understand the way a report layout is designed and executed.



Know how frequently used report properties are implemented in Report Definition Language Client (RDLC) report layouts.



Know how to build a request options page for the RDLC report layout.



Describe the prerequisites for report development in Microsoft Dynamics NAV 2013.



List the software prerequisites for report development.



List the hardware prerequisites for report development.



Explain where to find more information about Microsoft Visual Studio 2010.



Describe the roles of reports and know the anatomy of a report.



Explain the structure of reports in Visual Studio Report Designer.



Understand the rules for flattening data.



Understand the steps involved in creating a basic report.



Explain how to include a label, variable and expression.



Explain the creation of the layout of a report.



Document the User Experience (UX) guidelines for reports in Microsoft Dynamics NAV 2013.



Demonstrate how to view the dataset at runtime.



Describe how to set page options, paper size.



Understand the creation process for the dataset.



Know how frequently used report properties are implemented in RDLC report layouts.



Know what the request options page in a report is used for and how to build a request options page for the RDLC report layout.



Learn how to implement sorting and filtering in Microsoft Dynamics NAV 2013 reports.

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

1-3

Reporting in Microsoft Dynamics® NAV 2013

Prerequisites The prerequisites for report development in Microsoft Dynamics NAV 2013. It will include an explanation of the supported version(s) of Visual Studio and how to obtain and install it.

Visual Studio 2010 Professional To develop RDLC reports in Microsoft Dynamics NAV 2013, Visual Studio 2010 Professional or above is required. Visual Studio Report Designer offers several new options and features. Furthermore, due to its thorough integration with Microsoft SQL Server, it is possible to take advantage of the reporting capabilities of Microsoft Report Viewer, including the following. •

Richer formatting



Interactive sorting



Graphics and charts



Export possibilities (PDF, Microsoft® Office Excel® and Microsoft® Office Word®)

When you install Microsoft Visual Studio 2010 Professional (or a higher stock keeping unit (SKU)) you must select at least the following option, Visual Web Developer, as shown as in the following illustration. Visual Web Developer

FIGURE 1.1: VISUAL STUDIO CHECKLIST

1-4

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

Module 1: Creating Reports Software Requirements Visual Studio 2010 can be installed on the following operating systems. •

Windows Vista (x86 & x64) with Service Pack 2 - all editions except the Starter Edition



Windows 7 (x86 & x64)



Windows Server 2008 (x86 & x64) with Service Pack 2



Windows Server 2008 R2 (x64)

Supported Architectures include the following. •

32-Bit (x86)



64-Bit (x64)

Hardware Requirements To run Microsoft Visual Studio 2010, you will require the following hardware. •

A computer that has a 1.6 GHz or faster processor



1 GB (32 Bit) or 2 GB (64 Bit) RAM (Add 512 MB if running in a virtual machine)



3 GB of available hard disk space



5400 RPM hard disk drive



DirectX 9 capable video card running at 1024 x 768 or higherresolution display



DVD-ROM Drive

More information More information about Microsoft Visual Studio 2010 is available at the Microsoft website http://go.microsoft.com/fwlink/?LinkId=267132 Here you can discover what is new in Microsoft Visual Studio Professional, version 2010, the versions that are available and how to obtain them. For more information on Visual Studio products and solutions, including trials, MSDN subscriptions, partners, case studies and more, visit http://go.microsoft.com/fwlink/?LinkId=267133 For additional resources on getting started with Visual Studio products, visit http://go.microsoft.com/fwlink/?LinkId=267134

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

1-5

Reporting in Microsoft Dynamics® NAV 2013

Anatomy of Reports This lesson describes the roles and components of reports in Microsoft Dynamics NAV 2013. It describes some general concepts related to report objects.

Report Purposes Reports can print information from a database and they can structure and summarize information. Reports can also include calculations or expressions. Reports are used to print documents such as invoices and 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. Additionally, reports developed in Microsoft Dynamics have several purposes that include the following. •

Print information from a database in a structured way. Typical examples are the Customer - List and the Customer - Order Detail (reports 101 and 108).



Print a company's official documents. For example, report 206, Sales Invoice prints an invoice together with its relevant information.



Automate recurring tasks, such as updating all prices in the item list. This can be performed by using C/AL code in a codeunit. However, using a processing-only report makes it easier because of the powerful data modeling available for report design. For example, report 794, Adjust Item Costs/Prices.

A report consists of a report description. The report description specifies how data is collected (the logical design or the dataset) and presented on screen or on paper (the visual design or layout). The report description includes both the logical and the visual design and is not directly visible to the user.

1-6

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

Module 1: Creating Reports The following illustration shows components of a report and how they are related in Microsoft Dynamics NAV 2013.

FIGURE 1.2: REPORT DESCRIPTION DIAGRAM A report object is composed of a report dataset and a visual layout. You design a report by first defining the dataset and then designing the visual layout. Report objects also contain properties, triggers, code, and an optional request page. Summary In Microsoft Dynamics NAV 2013, to design a client report definition (RDLC) report, you design the data model with Report Dataset Designer and you design the layout with Visual Studio Report Designer. After you design reports, you can make them available in client applications. For example, you can add a report to the Report tab of a page. When you preview a report from a client computer, the report is displayed using Report Viewer.

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

1-7

Reporting in Microsoft Dynamics® NAV 2013 The Structure of Reports in Visual Studio The starting point for designing RDLC report layouts is the Object Designer. Reports run in Microsoft Dynamics NAV 2013 are designed in the Microsoft Dynamics NAV 2013 development environment. However, the RDLC report layout is built in Visual Studio. The Visual Studio Report Designer relies completely on the dataset you define in the Report Dataset Designer. Defining the Dataset You use Report Dataset Designer in the Microsoft Dynamics NAV development environment to define the dataset of a report. You build the report dataset from data items and columns. A data item is a table. A column can be one of the following. •

Field in a table



Variable



Expression



Text constant

Typically, data items correspond to fields in a table. When the report is run, each data item is iterated for all records in the underlying table with an appropriate filter defined. When a report is based on more than one table, you must set relations between the data items so that you can retrieve and organize the data. In Report Dataset Designer, you indent data items to establish a hierarchy of data items and control how the information is gathered. For example To create a report that displays a list of customers and lists the sales orders that were placed by each customer, you must define the following data items: •

A data item that corresponds to the Customer table.



A data item that corresponds to the Sales Order table.

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

1-8

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

Module 1: Creating Reports Properties The report description contains properties that are related to the report and the properties that are related to the other components of the report (dataset, columns, request page and controls). When designing reports in Visual Studio, you can also define a number of properties. These properties are saved in the RDLC data. Triggers Triggers represent predefined events that occur during report execution and that cause the system to execute specific user-definable C/AL statements. Triggers in a report can be divided into the following categories. •

Report triggers



Dataset triggers



Request page triggers



Request page control triggers

Designing the Visual Layout You build the visual layout of a report by arranging data items. A report that is displayed or printed must have a client report definition (RDLC) layout. You use Visual Studio Report Designer to design the RDLC layout. Microsoft Dynamics NAV 2013 supports RDLC 2008. You generally display most data in the body of a report, and you use the header to display information before any data item record is displayed. For example, you can display a report title, company, and user information in the header of a report. With Visual Studio Report Designer, you can add useful features to your report layouts, such as: •

Links from a field on a report to either a page or another report.



Images and graphs.



The ability to toggle columns so that you can hide or display data.



The ability for users to interactively change the column on which data in the report is sorted.



The ability to display RTF text.

A report in Visual Studio always has exactly one Body, and it is not possible to add more than one. Optionally it can have one Page Header and one Page Footer. Extra headers or footers cannot be added.

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

1-9

Reporting in Microsoft Dynamics® NAV 2013 You can enable the Header and Footer sections by right-clicking in a blank report area, then enabling or disabling the Page Header and Page Footer sections. When disabling a Page Header or Page Footer, the entire section is deleted. When the report runs, it first runs the Page Header, then the Page Body, and then the Page Footer. It will not run the Page Body for each record. Looping through records is done by using a Data Region in the body section. More information on Data Regions is discussed later in this material. However, now it is possible in RDLC2008, in the Page Header sections, to work with data fields. This is different from RDLC2005. The module on adding code to a report describes how to use expressions and custom coding to work with data fields in the header and footer. Reports use a variety of report items to organize data on a report page. Report items are available in the toolbox. You drag report items to the report design surface and then drag report data from the Report Data pane to the report items on the design surface. The design surface is not What You See Is What You Get (WYSIWIG). The report items have an initial layout position that can change when the report is processed. The following list describes typical uses for different report items: Textbox Use for titles, date stamps, and report names. Placeholder text appears in text boxes where you have linked data and layout items. The placeholder text is display text for an underlying report expression. During report processing, report data is substituted for the report expressions and the calculated values replace the placeholder text. Table, Matrix Use to display tabular or crosstab data from a report dataset. Table and Matrix are templates of a Tablix data region and provide a starting grid layout for data from a report dataset. Chart Use to graphically display data from a report dataset. You can also nest a chart inside a Tablix data region. Gauge Use to present a visual image for a single value within a range of values.

1 - 10

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

Module 1: Creating Reports List Use to create a free-form layout such as the forms on a webpage. A List is a template of a Tablix data region and provides a starting layout for data from a report dataset. Image Use to add existing images to a report. Line Use lines as graphical elements. Rectangle A rectangle can be used as a container for other report items. Use a rectangle to help control how report items such as data regions appear on a report page when the report is rendered. A typical report uses Tablix data regions. You drag fields from the Report Data pane and drop them on a Tablix cell for a data region, or to the Grouping pane to define groups for the selected data region.

Rules for Flattening Data The RoleTailored client report works with a flattened dataset. This means that data from multiple tables is joined before it is sent to the client. In the report dataset designer there can be multiple data items that might be indented or not. Depending on the indentation and relations between data items, a resultset is generated at runtime. This resultset is the result of the flattening of the indented data items into a two dimensional resultset. The rules for flattening data can be described as follows. •

Reports with one data item: This corresponds to a single SELECT Column FROM Table statement. The result can be displayed in the body section.



Reports with indented data items: This is similar to SELECT Column FROM Table A INNER/OUTER JOIN Table B ON Table A.Column = Table B.Column. If PrintOnlyIfDetail is set to True on the parent, an INNER join is used. If PrintOnlyIfDetail is set to False on the parent data item, an OUTER JOIN is used. The resulting set can then be displayed using grouping and filtering.

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

1 - 11

Reporting in Microsoft Dynamics® NAV 2013 •

Reports with multiple data items on the same level: This is similar to a UNION statement. Again, grouping and filtering can be needed to display the correct records. The difference with a UNION statement is that both dataitems will have different fields and a different number of columns. Actually, it is more like a concatenation of multiple resultsets.

The following dataset generation in both clients is explained based on an example. In this example, three posted sales invoices will be printed. The first sales invoice header, Invoice No. 1001, has four sales invoice lines of (Type = Item) to which two different value added tax (VAT) percentages apply. The second sales invoice (1002) has one line and is sold without VAT. The third invoice (1003) has one line, to which one single VAT percentage applies. The RoleTailored client works with a flattened dataset; this means that tables will be joined (in reports with multiple tables). The result of the queries will be one single dataset containing information from multiple tables. Once the dataset is available, the dataset can be processed using filtering and sorting and the report can be rendered. In the following illustration, the dataset will look like this (not all fields from the sales invoice report are included):

FIGURE 1.3: DATASET GENERATION The dataset combines information from three tables. For invoice 1001 six lines are included. Invoice 1002 has only one line, and invoice 1003 has two lines. The first four lines for invoice 1001 relate to the four sales invoice lines. The two other lines represent the VAT specification lines for the invoice. To generate the dataset, the logical model of the report is used.

1 - 12

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

Module 1: Creating Reports To select records from a single table, a simple SELECT statement is used. In this case, if the report contains several unindented data items, the tables will be merged using a UNION statement. The resulting recordset contains the fields from all data items in the report. When selecting records from multiple linked tables, the results of the SELECT statements must be concatenated. As a result, in reports with indented tables, data items will first be joined using the conditions specified in the DataItemLink property. In this case, the Sales Invoice Header and the Sales Invoice Line table will be joined, and all relevant fields will be selected. After handling the sales invoice lines, the report will proceed to the next data item. (In this example, it is assumed that no dimensions are specified.) Next, it will try to retrieve the VAT Amount Lines. Again, the Sales Invoice Header and the VAT Amount Line data items will be joined and the relevant fields will be selected from the data item. So far, several recordsets are now generated in the example. As a final step, these smaller recordsets will be merged through a UNION statement. As a result, the Sales Invoice Line and the VAT Amount Line recordsets will be merged into a recordset containing fields from all three tables, which results in the dataset that is shown.

Creating the Dataset This lesson explains how to add data items and columns in the dataset designer.

Creating a New Report To create a new report you will create a blank report and use Report Dataset Designer to add items to the dataset. Then you will use Visual Studio Report Designer to design the layout of the report. As an example, you will start by creating a simple list report, 1.

In the development environment, on the Tools menu, select Object Designer, or use the shortcut Shift-F12.

2.

In the Object Designer, click the Report button on the left side of the window, and then click the New button at the bottom of the Object Designer.

3.

The report dataset designer now opens. In the report dataset designer, the first line contains DataItem in the Data Type column. In the next column, Data Source, you can enter a table name or table number directly or use the lookup button to select the table from the list of tables.

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

1 - 13

Reporting in Microsoft Dynamics® NAV 2013 4.

In the next column, Name, you can enter the name of the data item. You can leave the default or enter a new name.

5.

For example, you can enter 18 as the table number as the Data Source. The system will, after you leave the column, update the table number to the table name: Customer. In the Name column it will set .

6.

To define the fields that you want to include from the table into the report dataset, you must create a line for every field from the table that you want to include.

7.

In the designer, on the first empty line, in the DataType column, select Column from the drop-down list.

8.

In the View menu, select the Field menu. The Field Menu window opens, and it displays a list of fields that you can add to the report dataset. You can select one or multiple fields in the field menu by holding down the SHIFT or CONTROL key. Click the OK button to add the selected fields in the Field menu to the report dataset.

FIGURE 1.4: FIELD MENU WINDOW 9.

To include the caption of a column in the dataset, select the Include Caption check box. It is the last column in the report dataset designer. The caption will become available as a parameter in Visual Studio Report Designer.

10. Repeat steps 1 through 9 in the report dataset designer to add data items and columns until you have added all the fields you want to include in the report. For example, select the No., Name, Address, Phone No. and Country/Region Code fields. 11. Make sure to select the Include Caption for all of the rows in the Report Dataset Designer.

1 - 14

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

Module 1: Creating Reports 12. On the File menu click Save. 13. In the Save As dialog box, in the ID field, enter an ID for the report. In the Name field, enter a Name for the report. 14. Click OK.

Include a Label You can add a label to the dataset, for example, if you want to add a title to the report, or a caption for a table. You can either add labels that are related to another data item, such as the caption for a table field, or labels that are not related to another data item, such as the title of the report. To add a label that is related to a column, use the following steps. 1.

2.

In Report Dataset Designer, do one of the following: a.

Select the Include Caption check box for a Column data type row to add a label for the column.

b.

Select a Column data type row for which you want to add a label to the dataset, and on the View menu, choose Properties. In the Properties window, set the IncludeCaption property to Yes.

Compile and save the report.

To add a label that is not related to a column follow the next steps. 1.

In Report Dataset Designer, on the View menu, choose Labels.

2.

In Report Label Designer, in the Name field, add a Common Language Specification (CLS)-compliant name for the label. This name is used in the Visual Studio Parameters.

3.

In the Caption field, enter the caption.

4.

On the View menu, choose Properties.

5.

If you have a Multilanguage application, then in the Properties window specify the values for the CaptionML property.

6.

Compile and save the report.

Note: The Common Language Specification (CLS), is a set of basic language features needed by many applications to fully interact with other objects regardless of the language in which they are implemented. More information about the Common Language Specification, visit: http://go.microsoft.com/fwlink/?LinkId=267137

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

1 - 15

Reporting in Microsoft Dynamics® NAV 2013 Include a Variable If you want to include a variable in the report dataset, then do the following. 1.

In Report Dataset Designer, on a blank line, in the Data Type column, select Column from the drop-down list.

2.

In the Data Source column, enter the variable. You can use the Lookup button to open the C/AL Symbol Menu dialog box and view the variables for the report.

3.

In Report Dataset Designer, in the Name column, enter a CLScompliant name for the variable. This name is used in the dataset in Visual Studio.

Include an Expression If you want to include a calculation or other source expression in the report dataset, then do the following. 1.

In Report Dataset Designer, on a blank line, in the Data Type column, select Column from the drop-down list.

2.

In the Data Source column, enter the source expression, such as FORMAT(TODAY,0,4).

3.

In the Name column, enter a CLS-compliant name for the variable. This name is used in the dataset in Visual Studio.

Creating the Layout This lesson covers how to create a layout in Visual Studio – (RDLC) It will show this by demonstrating how to create a simple list report.

Creating an RDLC Layout The previous lesson showed how to create the dataset for a report, which includes the following fields: No., Name, Address, Phone No. and Country/Region Code from the Customer table. After you save and compile the report in Report Dataset Designer, you must now design the layout in Visual Studio. For this report, you will display all the fields that you selected and display the company name in a larger font and then set it to bold. You will also display the date, time and username of the person that executed the report.

1 - 16

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

Module 1: Creating Reports To create the RDLC layout for the report, follow these steps. 1.

On the View menu, choose Layout. Visual Studio opens. The dataset in Visual Studio contains the dataset items that you added in Report Dataset Designer.

2.

From the toolbox, drag a Table control to the report layout.

3.

The table has only three columns so you will add two more columns to accommodate all the fields in the dataset.

4.

Right-click the third column and select Insert Column and then select Right to add a new column.

5.

Repeat step 4 to add another column.

FIGURE 1.5: ADD A COLUMN TO A TABLE WINDOW The next step is to populate the table with the data from the dataset. 6.

On the View menu, click Report Data. The Report Data window opens.

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

1 - 17

Reporting in Microsoft Dynamics® NAV 2013

FIGURE 1.6: REPORT DATA WINDOW 7.

From the Report Data window, under DataSource, and under DataSet_Result, drag the No. field to the first column, second row of the table in the Data section of the report layout.

8.

Under Data Sources, and under DataSet_Result, drag the Name field to the second column, second row of the table in the Data section.

9.

Under Data Sources, and under DataSet_Result, drag the Address field to the third column, second row of the table in the Data section.

10. Under Data Sources, and under DataSet_Result, drag the Phone No. field to the forth column, second row of the table in the Data section. 11. Under Data Sources, and under DataSet_Result, drag the Country_Region_Code field to the fifth column, second row of the table in the Data section. 12. From the toolbox drag three text boxes and place them above the table in the designer. These text boxes will display the date and time, the username and the company name. 13. Select and right-click the first text box and the click Expression to open the Expression Properties window. 14. Under Category, click Built-in Fields, double-click ExecutionTime and click OK. This expression displays the time the report is executed. 15. Select and right-click the second text box and the click Expression to open the Expression Properties window. 16. Under Category, click Built-in Fields, double-click UserID and click OK. This expression displays the user name for the user that executed the report.

1 - 18

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

Module 1: Creating Reports Note: It is recommended to add the UserID as a column to the dataset. By doing this, the Microsoft Dynamics NAV user ID will display, instead of the Windows user ID of the service tier, in a three tier environment. 17. Select and right-click the third text box and the click Text Box Properties to open the Text Box properties window. 18. Under the General tab, in the Value drop-down list, enter the company name. For this walkthrough, you can enter CRONUS International Ltd. and click OK. 19. Click Font and set the font size to a larger font and under Style, select Bold and click OK. For example, you can select 16 for the font size. 20. On the header row of the table, populate the text boxes with the Captions. 21. In the report dataset window, expand the Parameters folder. 22. Select the No_CustomerCaption and drag it onto the first text box of the header row. 23. Repeat this step for the other Captions as in the following screenshot:

FIGURE 1.7: ADD CAPTIONS TO THE TABLE WINDOW 24. You will format the text boxes for the field captions in the table to display in bold font. 25. Select and right-click the No. caption text box (first column and first row) and click Text Box Properties to open the Properties window. 26. Click the Font tab, and under Style, select the Bold check box and then click OK. 27. For the text boxes in the first row, set the captions to bold. 28. Close Visual Studio to go back to C/Side. Note: Visual Studio can remain open in case report development is not completely finished and you want to test and run the report.

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

1 - 19

Reporting in Microsoft Dynamics® NAV 2013 29. In Report Dataset Designer, select a new row. A dialog box shows the following message: The layout of report id: ' ' is changed by another application. Filename of the changed RDLC: ‘ ’ Do you want to load the changes? 30. In the dialog box, choose Yes to load the changes that you made to the RDLC layout into the report. 31. In the development environment, on the File menu, choose Save. 32. In the Save dialog box, select Compiled, and then choose OK. 33. To run the new report, in Object Designer, select the report and then choose Run. 34. The result will look like this:

FIGURE 1.8: CUSTOMER LIST REPORT WINDOW

1 - 20

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

Module 1: Creating Reports NAV 2013 UX Guidelines for Microsoft Dynamics NAV 2013 The following information is to be considered as general guidelines and recommendations regarding the user interface of Microsoft Dynamics NAV 2013 reports. The information used in the following table is shown in centimeters (cm), inches (in) and points (pt). Page Setup: Left

Right

Top

Bottom

A4 Portrait

2 cm

1 cm

1 cm

1 cm

A4 Landscape

1 cm

1 cm

2 cm

1 cm

Letter Portrait

0,5 in

0,5 in

0,5 in

0,5 in

Letter Landscape

0,5 in

0,5 in

0,5 in

0,5 in

Tabloid Portrait

0,5 in

0,5 in

0,5 in

0,5 in

Tabloid Landscape

0,5 in

0,5 in

0,5 in

0,5 in

Body size: Width

Height

A4 Portrait

18 cm

27,7 cm

(785 pt)

A4 Landscape

27,7 cm

18 cm

(510 pt)

Letter Portrait

7,5 in

10 in

(720 pt)

Letter Landscape

10 in

7,5 in

(540 pt)

Tabloid Portrait

10 in

16 in

(1152 pt)

Tabloid Landscape

16 in

10 in

(720 pt)

Report title: Font

Segoe UI 14 pt Bold

Cell height

20 pt

Padding

Cell padding: left: 5 pt, right: 5 pt, top: 0 pt, bottom: 0 pt

Text alignment

Document reports: Right; All other reports: Left

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

1 - 21

Reporting in Microsoft Dynamics® NAV 2013 Other text in the header: Font

Segoe UI 8 pts Regular

Cell height

10 pt

Padding

Cell padding: left: 5 pt, right: 5 pt, top: 0 pt, bottom: 0 pt

Space to Body: •

Height: 20 pt

Headers in the body: Font

Segoe UI 8 pt Bold

Cell height

10 pt

Padding

Cell padding: left: 5 pt, right: 5 pt, top: 0 pt, bottom: 0 pt

All other text: Font

Segoe UI 8 pts Regular

Cell height

10 pt

Padding

Cell padding: left: 5 pt, right: 5 pt, top: 0 pt, bottom: 0 pt

Line spacing: •

Grid 10 pt. Multiplication of 10s. (As a designer/developer, you can use your discretion to space the content.)

Table Header:

1 - 22



Row1: Title: Bold



Row2: Height: 2,5pt: Border bottom; black; solid; width: 1 pt



Row3: Height: 2,5pt



Row4: Text



Header row can be up to 30 pt in height if required (allowed to be up to 3 lines)



Vertical align: bottom

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

Module 1: Creating Reports Table content: •

Cell height is 10 pt



Cell padding: left: 5 pt, right: 5 pt, top :0 pt, bottom: 0 pt



Vertical align for cells: top (default)



If row below needs to be indented, add +10 to Left Padding

Cell colors: •

List reports: Alternate BackgroundColor= mod 2, “WhiteSmoke”, “White”



Height: 40 pt



Space below Logo: 10 pt

Logo:

Text alignment: Numeric/decimal fields

right aligned (including header)

Text fields

left aligned

Numeric text

left aligned (eg. customer no)

Date/time

left aligned

Link color: •

Blue (no underline)

Chart color: •

Pallette: BrightPastel

Additional Reading: More information, including examples, can be found here: http://go.microsoft.com/fwlink/?LinkId=267138

Demonstration: How to View the Dataset Using the “About This Report” Feature When you run a report, to view the underlying, flattened, dataset that is generated by Microsoft Dynamics NAV, you can enable an option at runtime in the report viewer.

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

1 - 23

Reporting in Microsoft Dynamics® NAV 2013 Demonstration Steps 1.

2.

First, you must run the report. Then when the report is being executed and displayed in the report viewer, you must enable the About This Report feature. This can be achieved by performing the following procedure. a.

In the report viewer, click the menu at the top-left of the window.

b.

A drop-down menu appears.

c.

In this drop-down menu select the Help, About This Report option. Alternatively, you can use the shortcut: Ctrl+Alt+F1.

A popup window now appears containing the following message: The About This Report feature is now active. Run your report again to view the dataset.

1 - 24

a.

Close the popup window.

b.

Close the report viewer.

c.

Run the report again.

d.

Repeat steps 1 through 3.

e.

A popup window now appears that displays the dataset of the report.

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

Module 1: Creating Reports

FIGURE 1.9: ABOUT THIS REPORT WINDOW 3.

In the popup window, a column will appear for every field from the report dataset and a row for every record. In the Action Pane of the popup window you will find the following actions. o

Recipient as Attachment: This action will create a new email and include the dataset as an HTML attachment.

o

Export as XML: This action will export the dataset to an XML file.

o

Microsoft Word: This action will export the dataset to a Microsoft Office Word document.

o

Microsoft Excel: This action will export the dataset to a Microsoft Office Excel document.

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

1 - 25

Reporting in Microsoft Dynamics® NAV 2013 o

Print Page: This option will send the dataset to the printer.

Note: Once the feature is enabled for a report, it will remain so until you close the client. It is recommended not to enable this feature for every report, because the dataset is kept in memory and will consume extra resources on the client.

Demonstration: How to Set Page Options To change the dimensions of the design area for a report, specify the settings you want to use in the Page Setup.

Demonstration Steps 1.

To Set Page Options: a.

Select Page Setup on the Report Properties dialog box to set page options for the entire report.

b.

You can do this via the Menu, Report, Report Properties and then select Page Setup on the left.

FIGURE 1.10: PAGE SETUP WINDOW

1 - 26

o

Inches: Specifies the page size in inches. By default, your local settings determine the page unit that is selected.

o

Centimeters: Specifies the page size in centimeters. By default, your local settings determine the page unit that is selected.

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

Module 1: Creating Reports o

Portrait: Specifies the page orientation of the report. Portrait indicates that the page is longer vertically.

o

Landscape: Specifies the page orientation of the report. Landscape indicates that the page is longer horizontally.

o

Paper size: Select a size from the list that automatically enters the dimensions in the Width and Height controls. Alternatively, select Custom Size and then change the Width and Height controls to reflect the size you want to use.

o

Width: Displays the width of the paper size that is selected in the Paper type list.

o

Height: Displays the height of the paper size that is selected in the Paper type list.

o

Top: Sets the distance between the top of the report and the top of the first line of the report.

o

Bottom: Sets the distance between the bottom of the report and the bottom of the last line of the report.

o

Left: Sets the distance between the left edge of the report and the left edge of the report rows.

o

Right: Sets the distance between the right edge of the report and the right edge of the report rows.

Demonstration: How to Set the Paper Size When you print a report, you can specify the size of the paper to use. The size of the paper determines the number of pages in a report and the report data that fits on each page. Paper size affects only reports that are rendered with the hard page-break renders: PDF, Image, and Print. Setting the paper size has no effect on other renderers. From the Report Viewer toolbar, you can export a report to a hard page-break renderer or click the Print button to print a copy of the report. You might need to set the paper size or other page setup properties. Use the Report Properties dialog box to change page setup properties, including the paper size. More information about pagination is provided in module 4, Design Considerations.

Demonstration Steps 1.

To change the paper size, perform the following steps. a.

Right-click outside of the report body and click Report Properties.

b.

In Page Setup, select a value from the Paper Size list.

c.

Each option populates the Width and Height properties.

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

1 - 27

Reporting in Microsoft Dynamics® NAV 2013 d.

You can also specify a custom size by typing numeric values in the Width and Height boxes.

e.

Click OK.

Size values have a default unit based on the user's local settings. To designate a different unit, type a physical unit designator such as cm, mm, pt, or pc after the numeric value.

Demonstration: How to Set the Body to Fit As demonstrated in the previous topic, you can set the paper size of the report in the report properties. It is recommended to also set the size of the Body to fit the report size. When you are adding report items to the body of a report, you will notice that the Body of the report might grow. Also, when you add a column to a Tablix, the Tablix data region will grow horizontally. This might increase the size of the body, and the size of the report body might become greater than the size of the report. As a result, when you run the report, the body will be split over multiple pages. More information about report pagination is available in the Interactive Features module.

Demonstration Steps 1.

To do this, perform the following steps. a.

In the drop-down list at the top, select Report.

b.

Copy the PageSize properties using your mouse or CTRL-C.

c.

In the drop-down list at the top of the Properties window, select Body.

d.

In the Size properties, paste the copied values using your mouse or CTLR-V.

The Microsoft Visual Studio Integrated Development Since the creation of the RDLC layout for reports in Microsoft Dynamics NAV 2013 is managed in Microsoft Visual Studio 2010 it is important to have a good understanding of Microsoft Visual Studio 2010. The Visual Studio product family shares a single integrated development environment (IDE) that is composed of several elements: the Menu toolbar, Standard toolbar, various tool windows docked or auto-hidden on the left, bottom, and right sides, and the editor space. The tool windows, menus, and toolbars available depend on the type of project or file you are working in.

1 - 28

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

Module 1: Creating Reports Menu Bar The menu bar appears at the top of the IDE and gives access to all features and commands in the Visual Studio IDE. Some familiar menu names are File, Edit, View, Tools, Window and Help. Each menu contains commands and command groups. Commands are functions that either launch submenus or accomplish tasks, such as printing a document, refreshing a view, or creating a new file. Depending on the type of project you are creating, new menus can appear (Format, Website, Data, and Report). Toolbars Toolbars are normally displayed at the top of the IDE, under the menu bar, but can be moved and docked to the left, right or bottom side of the IDE. Toolbars typically are rows of buttons and other controls (such as combination boxes, list boxes, text boxes, and splitter controls) that are associated with commands. When you click a toolbar button, its associated command is activated. Toolbar buttons usually have icons that suggest the underlying commands, such as a printer for a Print command. Like menus, toolbars are convenient graphical ways to present commands to users. Typically, related commands are clustered together on the same menu or toolbar. By default, not all available toolbars are displayed. To add additional toolbars, select View, Toolbars and check the toolbars to display. From the same menu, you can also choose to create new toolbars. Editors and Designers Microsoft Visual Studio includes multiple editors and designers that depend on the type of file or document that you are authoring. The Text editor is the basic word processor of the IDE, while the Code editor is the basic source code editor. Other editors, such as the CSS editor, the HTML Designer, and the Web Page Designer, share many of the features found in the Code editor, along with enhancements specific to the type of code or markup supported. Editors and designers usually have two views: a graphical design view and the code behind view (or source view). Design View lets you specify the location of controls and other items on the user interface or webpage. You can easily drag a control from the toolbox and place it on the design surface. Source View displays the source code for the file or document. This view supports coding help such as IntelliSense, collapsible code sections, code refactoring, and code snippet insertion. Other features include bookmarks and displaying line numbers.

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

1 - 29

Reporting in Microsoft Dynamics® NAV 2013 Some editors, such as the Web Page Designer and HTML Designer, also provide a hybrid view where both the graphical and code view of a file are visible simultaneously. This view is called the Split View. In the editor, you can have multiple files opened at a time. For each file that is opened in a project or solution, the code editor will contain a tab. You can easily switch from one file to another by clicking the tab. Solution Explorer The Solution Explorer displays solutions, their projects, and the items in those projects. From Solution Explorer, you can open files for editing, add new files to a project, and view solution, project, and item properties. Properties Editor The Properties window contains all properties for the item that is selected in the editors or designers. At startup, the window will show the properties of the field that is selected in the Solution Explorer. The contents of the window will be refreshed when you select another file in the Solution Explorer, or any object in the designers (text box, table row, and so on). When working in the code editor, the name of the code trigger being edited is visible. Toolbox The toolbox contains a list of controls that you can add to the design view of the project. The contents of the toolbox will vary depending on the type of project you are editing. To add controls from the toolbox to your project, drag and drop it to the Design view. You can add new controls to the toolbox by right-clicking the toolbox and selecting Choose Items. The toolbox window is often autohidden.

Dataset Patterns Reports in Dynamics NAV 2013 are executed in two steps, which reflect the two steps in the report design: first data set design in CSIDE followed by report layout design in Visual Studio: 1.

The C/AL runtime retrieves the data from the involved source tables, performs necessary calculations and combines the data in a single flattened dataset. This is performed by the NAV server.

2.

The produced dataset is transferred to the report viewer’s run-time hosted on the NAV client, which in turn renders the dataset data according to the report layout definition.

This lesson focuses on the first part, where report developers confront a particular challenge while having multiple source tables as the input, but a single consolidated data set as the output.

1 - 30

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

Module 1: Creating Reports The following examples illustrate and explain most of the typical patterns for data set design in Dynamics NAV reports in an easy to understand way. Various combinations of these patterns appear in real-life Dynamics NAV reports.

Demonstration Data To illustrate we introduce two simple NAV tables, which resemble the popular header-line pattern. The tables are populated with several rows of sample data. The “Header” table represents a simplified document header table, which has an integer “No.” field as the primary key and “Customer” fields to hold the customer name. No.

Name

11

Selangorian Ltd.

22

London Postmaster

33

Meyers Design

44

Total Solutions Inc.

The “Line” table represents a simplified order line with the “No.” field as the primary key; “Header No.” is a reference to the “Header” table, while the “Item” and “Quantity” fields represent the payload of the order line. No.

Header No.

Item

Quantity

111

11

Bicycle

1

222

11

Armchair

1

333

11

Toolkit

1

444

22

Armchair

2

555

22

Bicycle

2

666

44

Toolkit

4

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

1 - 31

Reporting in Microsoft Dynamics® NAV 2013 Linked Data Items This is a very common pattern for the datasets in Dynamics NAV reports. As shown on the following screenshot, the “Line” data item is nested in “Header” data item:

FIGURE 1.11: DATA ITEM DESIGNER WINDOW Note: The table relation, which connects Line.”Header No.” field with Header.”No.” field is defined as: Header No.=FIELD(No.) The resulting dataset at runtime contains 7 rows as shown in the “About this Report” feature:

FIGURE 1.12: DATASET OF REPORT WINDOW

1 - 32

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

Module 1: Creating Reports The fields from the header data item are repeated on the records from the related line data item. For example, header 11 is connected to 3 lines and as a consequence in each of the 3 records the header fields are repeated. In the resulting dataset certain fields might have no values. In this example, since the header row “33” – “Meyers Design” has no single linked line, all the fields from “Line” for this header are empty (marked as null). The produced data set is much equivalent to SQL LEFT Join operation on “Header”-“Line” tables.

Linked Data Items with PrintOnlyIfDetails This example has the same data set design as above, but the data item property PrintOnlyIfDetails property of the header data item is set to Yes.

FIGURE 1.13: USING PRINTONLYIFDETAILS WINDOW The property PrintOnlyIfDetails specifies whether to print data in a report for the parent data item when the child data item does not generate any output. Note: The PrintOnlyIfDetails property has no effect on a data item that does not have any child data items. If this property is No and there is no record in the child data item that corresponds to the current record in the parent data item, then the report prints data from the current record in the parent data item, even though there is no data for the child data item. If this property is Yes and there is no record in the child data item that corresponds to the current record in the parent data item, then the report does not print data from the current record in the parent data item. If there are more than two data items, then the report iterates through each parentchild relationship in the same way. Another way to achieve the result of not printing blank lines is to add a filter on the table. For example using the SETFILTER Function (Record).

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

1 - 33

Reporting in Microsoft Dynamics® NAV 2013 The resulting data set has fewer rows than above, since the Header lines without related Line records (e.g. “33” – “Meyers Design”) are excluded. Subsequently there are also no “null” fields anymore.

FIGURE 1.14: PRINT ONLY IF DETAILS WINDOW The produced data set is now similar to a SQL INNER Join operation on “Header”“Line” tables.

Nested Data Items without Link In this example there are still two nested data items, however the properties DataItemLinkReference and Data Item Link aren’t set, which effectively disconnects lines from the headers.

FIGURE 1.15: NO DATAITEMLINK WINDOW

1 - 34

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

Module 1: Creating Reports The resulting data set is much larger, since it includes all possible combinations of headers and lines, with absolutely no regard to their possible table relations. Since in our example there are 4 headers and 6 lines, the resulting dataset will contain 24 rows.

FIGURE 1.16: DATASET NO DATAITEMLINK WINDOW

Linked Data Items with an Integer Table The data set design from previous examples is not very practical for header-line reports, however it is widely used in case if one of the data items refers an Integer table, for example when producing several copies of certain rows or groups of rows in the resulting dataset. In this example we introduce another data item from the Integer table, which encloses the Header-Line data items ones. The purpose of such a design is to repeat Header-Line rows multiple times, for example to provide several copies of the same document.

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

1 - 35

Reporting in Microsoft Dynamics® NAV 2013 The following is a screenshot of the Report Dataset Designer of the report:

FIGURE 1.17: INTEGER DATAITEM IN DATASET WINDOW Note: The expression WHERE(Number=FILTER(1..2)) in DataItemTableView property of the Interger data item makes sure, that the outer data item will produce exactly two rows from the Integer table. The resulting data set now contains two identical set of Header-Line rows complemented by the NoOfCopy_Integer field:

FIGURE 1.18: DATASET OF INTEGER DATAITEM WINDOW

1 - 36

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

Module 1: Creating Reports The field NumberOfCopies_Integer is available in the dataset and can be used in the group expression of a data region, for example a List or Table.

Equally Nested Data Items In this example the same indentation level is used for both data items:

FIGURE 1.19: UNINDENTED DATAITEMS WINDOW The resulting data set combines the rows from both data items as in the following screenshot.

FIGURE 1.20: RESULTSET OF UNINDENTED DATAITEMS WINDOW

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

1 - 37

Reporting in Microsoft Dynamics® NAV 2013 All the rows from the Header table are included, but with empty fields for the Line table, followed by all the Line rows, but with empty fields for the Header table. The data set output is similar to SQL UNION operation on “Header”-“Line” tables.

Report Properties When designing reports in Microsoft Dynamics NAV, you can achieve good results without writing a single letter of code. Much can be done using properties. This lesson describes some properties that are frequently used in the report.

Report Properties Properties occur on many different levels in the report description. The following list shows the properties on the report level that are frequently used when designing reports. UseRequestPage You can use this property to decide whether the user of the report will be presented with a request page or not. If UseRequestPage is set to No, no request page will be shown. This implies that the user will not be able to choose a sorting order or to set filters and that the print dialog box will not be shown (that is, a report will be printed immediately). This property overrules any request page from the report. ProcessingOnly This property is used to set whether a report will produce graphical output, or will only be able to process data. If ProcessingOnly is set toYes, it is not possible to insert an RDLC layout. Additionally, the Print and Preview buttons in the request options form or page are replaced by an OK button. No graphical output is produced. (Any RDLC data part will be removed when setting the property to Yes.) PaperSourceFirstPage, PaperSourceDefaultPage and PaperSourceLastPage: In the Report - Properties window, in the PaperSourceFirstPage field, choose the paper source. The list contains 13 standard trays and 16 printer-specific trays. If the printer that is used for this report does not support the specified paper source, then the printer uses the default tray that is specified by the printer driver.

1 - 38

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

Module 1: Creating Reports If you do not specify a value for the PaperSourceFirstPage property, then the printer uses the tray that is specified in the PaperSourceDefaultPage property. If you do not specify a value for either the PaperSourceFirstPage property or the PaperSourceDefaultPage property, then the printer uses the default printer tray that is defined for the operating system. If you do not specify a value for the PaperSourceDefaultPage property, then the printer uses the default printer tray that is defined for the operating system. If you do not specify a value for the PaperSourceFirstPage property or the PaperSourceLastPage property, then the printer uses the tray that is specified in the PaperSourceDefaultPage property. The printer specific trays that are contained in the list are intended for use with printers that have other paper sources than the standard ones that are listed in the property. The settings in the Print and Page Setup dialog boxes override the value that is specified for the PaperSourceDefaultPage property. If you do not specify a value for the PaperSourceFirstPage/PaperSourceLastPage property, then the printer uses the tray that is specified in the PaperSourceDefaultPage property. If you do not specify a value for either the PaperSourceFirstPage/PaperSourceLastPage property or the PaperSourceDefaultPage property, then the printer uses the default printer tray that is defined for the operating system.

Data Item Properties The following list shows the properties on a data item level that are frequently used when designing reports. DataItemTableView Use this property to select one of the existing keys and the related, sort order and the filter for this data item. If a key is selected, the users of the report will not be able to select any key, sorting order or filters for that data item when the report is executed. As a result, there will be no tab for the current data item in the request page. If a sorting order is selected, it is suggested as the default if the users of the report select a sorting order. If a filter is selected, it is used together with the filters that the user specifies in the request page. Selecting a sorting order or a filter, or both, does not inhibit the user from selecting a key or adding another filter. The DataItemTableView property is a part of the logical design and does not apply to the RDLC report layout.

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

1 - 39

Reporting in Microsoft Dynamics® NAV 2013 DataItemLinkReference Use this property to specify the data item on a higher level for the indented data item it will be linked to. When you specify DataItemLinkReference, use the DataItemLink property to specify one or more fields from each data item to base the link on. This property is part of the logical design and impacts the dataset. DataItemLink Use this property to specify the corresponding fields from two data items that are linked by the DataItemLinkReference property. The link is defined as a property of the indented data item. This property is part of the logical design and impacts the dataset. PrintOnlyIfDetail Use the PrintOnlyIfDetail property to limit printing a data item that does not have a detailed data item. This property is evaluated when flattening the data. If the property is shown as False on the parent data item, the system uses an outer join select statement. ReqFilterFields Use this property to indicate those fields that will automatically be included on the tab of the request page that pertains to this data item. The user can set filters on these fields. When the request page is in use, the user will be able to add other fields and set filters on these fields. Even so, it is still recommended to use this property. If the underlying table has many fields, the occasional user of the report might not easily find the relevant fields to filter. If the user is not going to be able to put filters on other fields, you must remove the request page altogether by using the UseRequestPage property of the report, or remove the tab for this data item, by setting a specific key in the DataItemTableView property. ReqFilterHeading Use this property to create a caption for the request form tab that pertains to this data item. You can specify captions in different languages using the ReqFilterHeadingML property.

1 - 40

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

Module 1: Creating Reports Report Functions Apart from the properties, there are a number of C/AL statements that are often used in reports. CurrReport.Preview This property indicates whether a report is being printed in preview mode. If you run a client report definition (RDLC) report layout in preview mode and then call the CurrReport.PREVIEW function, then the Print icon, Print Layout icon, Page Setup icon, and Save As icon are not displayed. If you run a client report definition (RDLC) report layout in preview mode and do not call the CurrReport.PREVIEW function, then you can print from the Print Preview window. CurrReport.SKIP You can use the SKIP function to conditionally skip the processing of the current record. If the processing occurs inside a loop, the processing continues with the next record after the SKIP function is called. A typical situation in which you will use the SKIP function is when you want to retrieve records from a related table by using values in the current record for forming a filter. If the values in the current record already indicate that no records from the related table will be retrieved, there is no need to perform this processing and you can use the SKIP function to avoid the processing. CurrReport.BREAK The BREAK function exits from a loop or a trigger in a data item trigger of a report. BREAK causes the current trigger to end. It breaks the iteration of the current data item. CurrReport.QUIT When you use the QUIT function, the report is exited without committing any changes that are already made to the database during the execution. The OnPostReport trigger will not be called.

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

1 - 41

Reporting in Microsoft Dynamics® NAV 2013 CurrReport.LANGUAGE For the documents that you want to print in the language of the recipient, rather than in your own working language, you can add a single line of code in the document. This functionality is already enabled for most reports in the standard Microsoft Dynamics NAV database. The document is printed in the language that is specified in the Language Code field in the Customer Card window. In reports that need the multiple document languages functionality, you must insert the following C/AL code as the first line in the OnAfterGet Record() trigger. CurrReport.LANGUAGE := Language.GetLanguageID("Language Code") For each of these reports, you must create a new variable, Language, with the data type Record pointing to the Language table (table 8). When you have compiled the object, it will no longer print in the user’s working application language if another language is specified in the Customer Card window.

Building the Request Page When a report is run, the request page is displayed. The request page is a special window the user can use to define output options for the report. In some cases there is an extra tab called Options that is not related to a data item. It contains general information that determines the output and the execution of the report. The request page is displayed when the report is run. Its purpose is to let the user provide additional input before previewing or printing the report.

The Request Page A request page is a page that is run before the report starts to execute. Request pages enable end users to specify options and filters for a report. When a new report is created, a request page is automatically created for the report. Additionally, custom options can be created in the request page. These options are designed by using the Request Options Page Designer that 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.

1 - 42

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

Module 1: Creating Reports You design the Options FastTab of a request page by using Request Options Page Designer in the development environment. To access Request Options Page Designer, open Report Dataset Designer, choose View, and then choose Request Page. You design the filters on request pages by using the following report properties. •

ReqFilterHeading



ReqFilterHeadingML



ReqFilterFields

In addition to specifying options and filters, users can choose from the following actions on a request page, •

Print o

Print

o

PDF

o

Microsoft Word

o

Microsoft Excel



Preview



Cancel

For more information on how to design and edit the Request Page, refer to the C/SIDE Introduction in Microsoft Dynamics NAV 2013. The fields that you define as ReqFilterFields are shown on the request page. Additionally, an end user can add more fields on which to filter to the request page. It is recommended that you add fields that the end users of the report will frequently set filters on. By default, for every data item in the report, a FastTab for defining filters and sorting is created on the request page. To remove a FastTab from a request page, do not define any ReqFilterFields for the data item and set the DataItemTableView property to define sorting. The request page is displayed but there is no tab for this data item. If a DataItemTableView is not defined, then end users can select a sort field and sort order at runtime. If you set UseReqPage to No, then the report will start to print as soon as it is run. In this case, end users cannot cancel the report run. It is still possible to cancel the report, but some pages might print. In a complex report that uses data from several tables, the functionality can depend on a specific key and sort order. Design your reports so that end users cannot change the sort order in a way that affects the functionality of the report.

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

1 - 43

Reporting in Microsoft Dynamics® NAV 2013 Demonstration: Open the Request Page Susan talks to many customers during her daily job, and now she has another request for Mort. Some customers want to have item pictures included on the sales quote document. She asks Mort if it is possible to include this as an option on the Request Options Page. Mort agrees to change the Request Options Page.

Demonstration Steps 1.

To open the Request Page. a.

Open the Microsoft Dynamics NAV 2013 demonstration database.

b.

Open the CRONUS International Ltd. demonstration company.

c.

Select Tools, Object Designer to open the Object Designer.

d.

Select File, Import.

e.

Browse to the report R123456704.fob.

f.

Click OK to start the import.

g.

In the dialog box, choose to open the Import Worksheet window.

h.

In the Action column, verify that the action is set to Create.

i.

Click Open to import the object in the database.

j.

Select Tools, Object Designer.

k.

Click the Report button.

l.

Select report 123456704, Sales Quote.

m. Click the Design button. n.

Select View, Request Page.

Mort is now ready to change the Request Options Page.

FIGURE 1.21: REQUEST OPTION WINDOW

1 - 44

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

Module 1: Creating Reports Note: Note that adding a field in the request options page will not change the report layout. In order for the images to show/hide the RDLC layout needs to be updated accordingly.

Sorting and Filtering When you develop reports for Microsoft Dynamics NAV 2013, you must keep performance in mind. Because a company’s database will grow, and as a result, reports will have to aggregate more data over time. Helping users locate the data they need is key and integrating sorting and filtering in reports will provide an added value.

Sorting Data Data can be sorted in many ways. In Microsoft Dynamics NAV, each sort order is directly related to a table key. Meaning, you can have as many sorting orders as there are keys in your table. You can define up to 40 keys (one primary, 39 secondary keys) in a table. Sorting can be defined several ways, including the following. •

Use the DataItemTableView property to define the sorting of a data item. Select any of the keys that are defined in the table and also determine the sorting order (ascending or descending). Sorting methods that are defined here cannot be modified by the user. When specifying a Key in the DataItemTableView property, the Sort button is removed from the Request Options page. Additionally, the tab for the corresponding data item is removed from the Request Options page (unless request filter fields are specified in the ReqFilterFields property of the same data item).



The user can decide how the data will be sorted. In this instance, do not specify a Key in the DataItemTableView property of the data item. (Specify the Order if necessary.) When a user prints a report, he or she can click the Sort button and define both the Key and the Order to use in the Sort window. Remember that the Order selected in the Sort window will overrule the Order specified in the DataItemTableView.

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

1 - 45

Reporting in Microsoft Dynamics® NAV 2013 •

Use coding to define the sorting programmatically. One way is to define the sorting hardcoded in the C/AL Code using the SETCURRENTKEY statement. An alternative and more flexible solution is for the user to select from a limited set of sorting methods on the Request Options page (and then tie the options to a specific SETCURRENTKEY statement). Remember that programmatic sorting overrules the sorting defined in the Sort window or the DataItemTableView property.

The RDLC report layout offers another option to sort data. In Visual Studio Report Designer, you can specify additional sorting methods for any matrix or table control. To do this, right-click a table or matrix control and select Properties. On the Sorting tab, define a custom sorting order.

FIGURE 1.22: ADDITIONAL SORTING DEFINED IN THE TABLIX PROPERTIES WINDOW You can specify sorting options that do not match an existing key. For example, you can have your sales orders list sorted on Order Date, although the Sales Header table does not contain a corresponding key.

1 - 46

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

Module 1: Creating Reports Note: In the RDLC reports, it is not necessary for the Microsoft Dynamics NAV keys to sort. In this instance the sorting will occur in the Report Viewer and might take longer to complete.

Filtering Data A user can use filtering to limit the data that is included in a report. Several ways to perform filtering include the following. •

Use request filter fields: Request filter fields offer a variable way of filtering information. The user can decide whether or not to apply any filters. If any filter is specified, it is applied. If no filters are specified, all information is available. The advantage is that the designer can solve multiple reporting needs with one report. The disadvantage is that the user can set any filters and possibly manipulate the report output.



Use the DataItemTableView property to set a filter on a data item inside the report: Filters that are defined inside a report cannot be removed. The filter in the DataItemTableView is not translated into explicit filtering criteria in the RDLC report layout. Instead, the filter is applied on the service tier, before the dataset is sent to the client.



Use code to set some filters: Using code to set filters requires both programming skills and access to the C/AL Editor. Hardcoded filters can be set with the SETRANGE and SETFILTER statements. The disadvantage is that these filters are inside in the report and cannot be removed by the user. The report can only serve specific purposes. The advantage is that the report output cannot be manipulated.

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

1 - 47

Reporting in Microsoft Dynamics® NAV 2013 Inside the Visual Studio IDE there is another way to define some filters. Additional filtering can be defined by setting the properties of any Table or Matrix control. To define additional filter criteria, right-click any table or matrix control, and select Properties. On the Filters tab, define the filters.

FIGURE 1.23: TABLIX FILTER PROPERTIES WINDOW Filters that are defined inside Visual Studio cannot be removed by the user. An alternative for defining hardcoded filters in the C/AL Editor is to use variables on the Request Options page and use these variables as a filter. To do this, the variables must be part of the dataset, meaning they must be added to the Report Dataset Designer. There is no option to specify parameters at runtime. Parameters are used only for Captions and Labels.

1 - 48

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

Module 1: Creating Reports Best Practice: It is considered a best practice to avoid filtering in the RDLC layout of the report. When you apply a filter in the RDLC layout, it means the data will be fetched from the database, then sent to the report viewer and then it will be filtered. If the filter is applied in the Report Dataset Designer, then only the required data is fetched from the database and sent to the report viewer. Sometimes, when you know the values that will be used for the filters in advance, it is more advantageous to apply the filter(s) in the report dataset instead of in the RDLC layout. However, with the RDLC layout, you can use variables and expressions for dynamic filtering. If, when you design the report, you do not know the exact values that will be used for filtering, then you can use expressions, variables and parameters to filter in the RDLC layout. The dataset is sent from Microsoft Dynamics NAV Server into the memory on the client machine. If the dataset is larger than the amount of memory that is available, then the operating system might stop allocating more memory and the client might stop responding. To avoid this scenario you can try to reduce the dataset by applying appropriate filters that reduce the amount of data that needs to be retrieved and processed in a report.

Demonstration: Adding Sorting and Filtering Kevin, the Sales Manager, is using report 123456715, Salesperson Commission, to calculate and monitor the performance of his salespersons. He notices that the report contains lines where all the amounts are zero. He asks Mort to filter the report so that it only contains lines where both the Sales (LCY) and Profit (LCY) fields are different from zero. Additionally, he wants the details sorted by posting date, in descending order.

Demonstration Steps 1.

To add sorting and filtering. a.

Open the Microsoft Dynamics NAV 2013 demonstration database.

b.

Open the CRONUS International Ltd. demonstration company.

c.

Select Tools, Object Designer to open the Object Designer.

d.

Select File, Import.

e.

Browse to the report R123456715.fob.

f.

Click OK to start the import.

g.

In the dialog box, choose to open the Import Worksheet window.

h.

In the Action column, verify that the action is set to Create.

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

1 - 49

Reporting in Microsoft Dynamics® NAV 2013 i.

Click Open to import the object in the database.

j.

Click the Report button.

k.

Select report 123456715, Salesperson Commission.

l.

Click the Design button.

m. Select View, Layout. n.

Select Table1 in the Body section. Right-click any cell in the table and choose Select 'Table1'.

o.

Right-click the shaded border and select Properties.

p.

Select the Sorting tab.

q.

Click the Add button.

r.

In the Sort by field, select [Cust__Ledger_Entry__Posting_Date_].

s.

In the Order column, select Z-A.

t.

Select the Filters tab.

u.

In the Filter list, add the criteria as shown in the following illustration.

FIGURE 1.24: CHANGE FILTERS WINDOW

1 - 50

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

Module 1: Creating Reports v.

Click OK to close the Tablix Properties window.

w. Exit Visual Studio. x.

Load the changes.

y.

Save and compile the report.

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

1 - 51

Reporting in Microsoft Dynamics® NAV 2013

Lab 1.1: Creating a Table Report Scenario Your company has implemented Microsoft Dynamics NAV 2013 and some additional reports need to be created. Throughout the labs, you will be assigned the role of Mort, a customization developer in the Information Technology (IT) Department. Mort is mainly responsible for fixing problems and implementing features and customizations in the internal IT applications. Kevin, the Sales Manager, has asked for an overview of the customer sales and profit (in local currency) by salesperson. The list needs to contain totals by salesperson, by country/region code, by customer and by document type. The list also needs to contain a grand total for all salespersons. The report is not finished yet. Only a draft version of the object exists, containing the correct data model and two sections. Your task is to build the report for the RoleTailored client, from scratch.

Objectives The purpose of this lab is to create a RoleTailored client report with a table layout from scratch. You will learn how to add formatting to specific fields, and will add grouping and totaling. In the next modules, you will add some additional functionality to the report.

Exercise 1: Create the Report Exercise Scenario Build a report showing the following. •

Total sales (LCY) and total profit (LCY) by document type, by customer no., by country/region code and by salesperson



Subtotals for each group



Grand total for all salespersons

Dates and totals in the report must be formatted as defined in Microsoft Dynamics NAV.

1 - 52

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

Module 1: Creating Reports Task 1: Import Report 123456700 High Level Steps 1.

To import the object in the demonstration database, use the following procedure.

Detailed Steps 1.

To import the object in the demonstration database, use the following procedure. a.

Open the Microsoft Dynamics NAV 2013 demonstration database.

b.

Open the CRONUS International Ltd. demonstration company.

c.

Select Tools, Object Designer to open the Object Designer.

d.

Select File, Import.

e.

Browse to the report R123456700.fob.

f.

Click OK to start the import.

g.

In the dialog box, choose to open the Import Worksheet window.

h.

In the Action column, verify that the action is set to Create.

i.

Click Open to import the object in the database.

Task 2: Open the Object in Visual Studio High Level Steps 1.

First, start the Visual Studio development environment to create the RDLC report layout.

Detailed Steps 1.

First, start the Visual Studio development environment to create the RDLC report layout. a.

In the Object Designer, open report 123456700, Sales by Salesperson - L1.1 in design mode.

b.

Select View, Layout to open Microsoft Visual Studio.

c.

Visual Studio will open and show a blank Report Layout.

Task 3: Add a Table to the Report High Level Steps 1.

Next, add some controls from the Toolbox window to the Report Layout window. The Toolbox window is normally displayed on the left side of the Visual Studio IDE. If not, it can be made visible by pressing Ctrl+Alt+X.

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

1 - 53

Reporting in Microsoft Dynamics® NAV 2013 Detailed Steps 1.

Next, add some controls from the Toolbox window to the Report Layout window. The Toolbox window is normally displayed on the left side of the Visual Studio IDE. If not, it can be made visible by pressing Ctrl+Alt+X. a.

In the Toolbox window, click the Table control.

b.

Click in the Body section to add a table to the report. (You can also drag the Table control to the Body section.)

The report now contains a table with two rows (header, data) and three columns.

Task 4: Add Columns to the Table High Level Steps 1.

The following steps show how to add additional columns to the table.

Detailed Steps 1.

The following steps show how to add additional columns to the table. a.

Select any cell in the table. Now a grey bar is displayed above each column: the column handle. The column handle can be used to select and/or resize a column.

b.

Right-click the column handle above the third column and select "Insert column to the right." A new column will be added to the table. The new column will have the same width as the selected column.

c.

Repeat steps 1 and 2 three times.

As a result, the table will have two rows and seven columns.

Task 5: Add Dataset Elements to the Table High Level Steps 1.

The dataset is generated based on the report dataset designer. The following steps show how to add dataset elements to the table.

Detailed Steps 1.

1 - 54

The dataset is generated based on the report dataset designer. The following steps show how to add dataset elements to the table. a.

In the Report Data window, select an item from the dataset. For example, select Customer__Salesperson_Code_.

b.

Drag the selected element to a cell in the detail row of the table. In this case drag it to the first column in the Detail row.

c.

Select the Customer__Country_Region_Code_ and drag it to the second column on the Detail row.

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

Module 1: Creating Reports d.

Select the Cust__Ledger_Entry__Customer_No__ and drag it to the third column on the Detail row.

e.

Select the Cust__Ledger_Entry__Document_Type_ and drag it to the fourth column on the Detail row.

f.

Select the Cust__Ledger_Entry__Posting_Date_ and drag it to the fifth column on the Detail row.

g.

Select the Cust__Ledger_Entry__Sales__LCY__ and drag it to the sixth column on the Detail row.

h.

Select the Cust__Ledger_Entry__Profit__LCY__ and drag it to the seventh column on the Detail row.

i.

Save and close Visual Studio. You will be redirected to the Report Designer. Press Esc to leave the Report Designer. The following dialog box will be displayed.

FIGURE 1.25: MICROSOFT DYNAMICS NAV DIALOG BOX j.

Click Yes to load the RDLC layout in the report object. (If you select No, all changes made in the previous steps will be discarded, and the previous RDLC layout will be retained.)

k.

Click Yes to save the object.

Task 6: Run the Report High Level Steps 1.

To check the layout of the report, run the report.

Detailed Steps 1.

To check the layout of the report, run the report. a.

In the Object Designer, select the report and click Run. The RoleTailored client will be started and the request page of the report will be displayed.

b.

Click the Preview button to run the report. The result will appear similar to the following image :

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

1 - 55

Reporting in Microsoft Dynamics® NAV 2013

FIGURE 1.26: SALES REPORT PREVIEW WINDOW

Task 7: Add Currency Formatting to the Report High Level Steps 1.

In the Print Preview notice, some of the fields that show amounts (decimal values) are not formatted correctly—some have decimals— some do not, to reflect the same formatting in the RoleTailored client, you will need to change the formatting of the Sales (LCY) and Profit (LCY) fields in the report.

Detailed Steps 1.

1 - 56

In the Print Preview notice, some of the fields that show amounts (decimal values) are not formatted correctly—some have decimals— some do not, To reflect the same formatting in the RoleTailored client, you will need to change the formatting of the Sales (LCY) and Profit (LCY) fields in the report. a.

Open report 123456700 in Visual Studio.

b.

Select the Sales (LCY) field in the detail row.

c.

Right-click the cell and select Placeholder Properties.

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

Module 1: Creating Reports d.

Select the Number tab. On this tab, there are two options to define a format: by using a format, or by using an expression. If a format is being used, you can either select a standard format, or build your own custom format. However, you want to use the same formatting that is defined in the G/L Setup window. From previous steps, you know that the dataset also contains special formatting elements for decimal fields. These elements can only be selected using an expression.

e.

Select the Custom option in the Category column.

f.

Click the [Fx] button next to the Custom Format field. The Expression window is displayed.

g.

Double-click the Cust__Ledger_Entry__Sales__LCY__Format element in the Fields (DataSet_Result) category.

h.

Click OK to close the Expression window.

i.

Click OK to close the Placeholder Properties window.

j.

Repeat steps 2 through 9 to format the Profit (LCY) field using the Cust__Ledger_Entry__Profit__LCY__Format element.

k.

Save and Exit Visual Studio, import the new RDLC layout in the object, save the object and run it.

The result will appear similar to the following image.

FIGURE 1.27: SALES REPORT PREVIEW WINDOW

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

1 - 57

Reporting in Microsoft Dynamics® NAV 2013 Task 8: Decimal and Thousand Separators High Level Steps 1.

By default, the decimal separator is "." while the thousand separator is ",". Both separators are not defined hardcoded; they depend on the language of the report. The language can be defined using the Language property of the report. As with decimal formatting, you can use either a specific value (that applies for all users in all cases) or use an expression to make it user-dependent.

Detailed Steps 1.

1 - 58

By default, the decimal separator is "." while the thousand separator is ",". Both separators are not defined hardcoded; they depend on the language of the report. The language can be defined using the Language property of the report. As with decimal formatting, you can use either a specific value (that applies for all users in all cases) or use an expression to make it user-dependent. a.

Open the report in Visual Studio.

b.

In the Properties window, make sure Report is selected in the drop-down list.

c.

Select the Language property. Note that the default value is set to "=User!Language" which explains the current decimal and thousand separator.

d.

Save and Exit Visual Studio, import the new RDLC layout in the object, save the object and run it.

e.

The result will appear similar to the following image.

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

Module 1: Creating Reports

FIGURE 1.28: SALES REPORT WITH SEPERATORS PREVIEW WINDOW

Task 9: Add Date Formatting to the Report High Level Steps 1.

In the Print Preview notice that has the dates in the report still displayed as a Date Time field, you will need to change the formatting of the Posting Date field. Perform the following steps to add date formatting.

2.

Run the RoleTailored client report. Notice that all posting dates are formatted as defined in the report. You can also define the date format in Visual Studio. To have the date formatted as MM-DD-YYYY, perform the following steps.

Detailed Steps 1.

In the Print Preview notice that has the dates in the report still displayed as a Date Time field, you will need to change the formatting of the Posting Date field. Perform the following steps to add date formatting. a.

Open the report in the Report Dataset Designer.

b.

Select the line containing the Posting Date field and select Properties.

c.

In the Properties window, set the SourceExpr property to: FORMAT("Cust. Ledger Entry"."Posting Date", 0, '-')

d.

Save and compile the report in the Report Designer.

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

1 - 59

Reporting in Microsoft Dynamics® NAV 2013 2.

Run the RoleTailored client report. Notice that all posting dates are formatted as defined in the report. You can also define the date format in Visual Studio. To have the date formatted as MM-DD-YYYY, perform the following steps. a.

Open the report in the Report Designer.

b.

Select the line containing the Posting Date field and select Properties.

c.

In the Properties window, set the SourceExpr property to "Cust.Ledger.Entry"."Posting Date". (Remove the format instruction entered earlier.)

d.

Open the report in Visual Studio.

e.

On the detail row, right-click the text box containing the Posting Date field and select Textbox Properties.

f.

In the Textbox Properties window, click the Number tab.

g.

In the Category, select the Custom option.

h.

In the text box, enter MM-dd-yyyy.

i.

Click OK to close the Textbox Properties window. The specified date format will be copied to the Format code field in the Textbox Properties window.

j.

Save and Exit Visual Studio.

The dates are now formatted according to the specified formula. Date formats specified in the Report Dataset Designer will not overrule any format defined in Visual Studio.

Task 10: Add Grouping to a Report High Level Steps 1.

Add a grouping to the table.

2.

Add a new grouping for the Country/Region Code field.

3.

Add a new grouping for the Customer No. field.

4.

Add a new grouping for the Document Type field.

5.

Delete the detail columns that were added as groups.

Detailed Steps 1.

1 - 60

Add a grouping to the table. a.

Open the object in the RDLC design mode.

b.

Select any cell in the table. The column and row handles appear.

c.

Select the detail row by clicking the row handle.

d.

Right-click the row handle for the detail row and select Add group, Parent Group.

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

Module 1: Creating Reports e.

In the Group by list box, select the [Customer__Salesperson_Code_] element.

f.

Select the check boxes: Add group header and Add group footer.

g.

Click OK to close the Grouping Properties window.

Notice two new rows are added to the table: a group header row (above the detail row) and a group footer row (below the detail row). Also notice that at the bottom of the screen, Group1 and Details are listed in the Row Groups window. 2.

Add a new grouping for the Country/Region Code field. a.

Click the Group1 drop-down list in the Row Groups window.

b.

Select Add group, Child Group.

c.

In the Group by list box, select the [Customer__Country_Region_Code_] element.

d.

Select the check boxes: Add group header and Add group footer.

e.

Click OK to close the Grouping Properties window.

Notice that two new rows are added to the table: a group header row (above the detail row) and a group footer row (below the detail row). Also notice that a Group2 is added below Group1 in the Row Groups window. 3.

4.

Add a new grouping for the Customer No. field. a.

Click the Group2 drop-down list in the Row Groups window.

b.

Select Add group, Child Group.

c.

In the Group by list box, select the [Customer__No__] element.

d.

Select the check boxes: Add group header and Add group footer.

e.

Click OK to close the Grouping Properties window. Notice that two new rows are added to the table: a group header row (above the detail row) and a group footer row (below the detail row). Also notice that a Group3 is added below Group2 in the Row Groups window.

Add a new grouping for the Document Type field. a.

Click the Group3 drop-down list in the Row Groups window.

b.

Select Add group, Child Group.

c.

In the Group by list box, select the [Cust__Ledger_Entry__Document_Type_] element.

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

1 - 61

Reporting in Microsoft Dynamics® NAV 2013

5.

d.

Select the check boxes: Add group header and Add group footer.

e.

Click OK to close the Grouping Properties window. Notice that two new rows are added to the table: a group header row (above the detail row) and a group footer row (below the detail row). Also notice that a Group4 is added below Group3 in the Row Groups window.

Delete the detail columns that were added as groups. a.

Since we have added the Salesperson Code and Country Region Code as groups they are no longer required at the detail level of the report.

b.

Select the column header containing the Salesperson Code fields at the detail level (column 5).

c.

Right click the column header and select Delete.

d.

Repeat the last to steps for the column that contains the Country Region Code field (column 6).

e.

Save and Exit Visual Studio, import the new RDLC layout in the object, save the object and run it.

The result will appear similar to the following image.

FIGURE 1.29: SALES REPORT WITH DATE FORMATTING PREVIEW WINDOW

1 - 62

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

Module 1: Creating Reports Task 11: Add Subtotals to a Report High Level Steps 1.

The following steps show how to add totaling to a report.

Detailed Steps 1.

The following steps show how to add totaling to a report. a.

Open the object in the RDLC design mode.

b.

Right-click in the text box of the sixth column on the group footer row for the Country/Region Code group.

c.

Select Expression in the drop-down list that appears.

d.

In the Expression Editor that opens, type: =Sum(Fields!Cust__Ledger_Entry__Sales__LCY__.Value).

e.

Specify the correct format for the subtotal.

f.

Right-click in the text box of the seventh column on the group footer row for the Country/Region Code group.

g.

Select Expression in the drop-down list that appears.

h.

In the Expression Editor that opens, type: =Sum(Fields!Cust__Ledger_Entry__Profit__LCY__.Value).

i.

Specify the correct format for the subtotal.

j.

Save and Exit Visual Studio, import the new RDLC layout in the object, save the object and run it.

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

1 - 63

Reporting in Microsoft Dynamics® NAV 2013 The result will appear similar to the following image.

FIGURE 1.30: SALES REPORT WITH SUBTOTALS PREVIEW WINDOW

Task 12: Add Grand Totals to a Report High Level Steps 1.

The following steps show how to add grand totals to a report.

Detailed Steps 1.

1 - 64

The following steps show how to add grand totals to a report. a.

Open the object in the RDLC design mode.

b.

Right-click in the text box of the sixth column on the table footer row.

c.

Select Expression in the drop-down list that appears.

d.

In the Expression Editor that opens, type: =Sum(Fields!Cust__Ledger_Entry__Sales__LCY__.Value).

e.

Specify the correct format for the grand total.

f.

Repeat steps 2 through 5 for the Cust__Ledger_Entry__Profit__LCY__ field.

g.

Save and Exit Visual Studio, import the new RDLC layout in the object, save the object and run it.

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

Module 1: Creating Reports The result will appear similar to the following image.

FIGURE 1.31: SALES REPORT WITH GRAND TOTALS PREVIEW WINDOW The layout at the current state of development is not user friendly. In the next module you will further enhance the layout and fine-tune the report.

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

1 - 65

Reporting in Microsoft Dynamics® NAV 2013

Lab 1.2: Creating a Matrix Report Scenario Ellen is the Warehouse Manager, and one of her tasks is to optimize the entire warehouse. She ensures that item inventory levels are accurate and that periodic physical inventory counts occur. Ellen asks Mort to build a report showing the item inventory by location.

Objectives The purpose of this lab is to create a RoleTailored client report with a matrix layout from scratch. You will learn how to add formatting to specific fields, and how to add grouping and totaling. The classic layout is available as a separate object on the training DVD, namely report R123456701.fob. Use this as a starting point. In the next modules, you will add some additional functionality to the report.

Exercise 1: Build a Matrix Report. Exercise Scenario Build a matrix report for report 123456701 showing the total Inventory by Location Code. Location codes need to be printed as bold white text on a dark blue background. Item numbers need to be printed as black text on an orange background.

Task 1: Import Report 123456701 High Level Steps 1.

To import the object in the demonstration database, use the following procedure.

Detailed Steps 1.

1 - 66

To import the object in the demonstration database, use the following procedure. a.

Open the Microsoft Dynamics NAV 2013 demonstration database.

b.

Open the CRONUS International Ltd. demonstration company.

c.

Select Tools, Object Designer to open the Object Designer.

d.

Select File, Import.

e.

Browse to the report R123456701.

f.

Click OK to start the import.

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

Module 1: Creating Reports g.

In the dialog box, choose to open the Import Worksheet window.

h.

In the Action column, verify that the action is set to Create.

i.

Click OK to import the object in the database.

Task 2: Open the Object in Visual Studio High Level Steps 1.

The first thing to do is to start the Visual Studio development environment to create the RDLC report layout of the report.

Detailed Steps 1.

The first thing to do is to start the Visual Studio development environment to create the RDLC report layout of the report. a.

In the Object Designer, open report 123456701, Item Matrix L1.2 in design mode.

b.

Select View, Layout to open Microsoft Visual Studio.

Visual Studio will open and show a blank Report Layout.

Task 3: Add a Matrix Control to the Report High Level Steps 1.

To add the Matrix to the report follow these steps.

Detailed Steps 1.

To add the Matrix to the report follow these steps. a.

In the Toolbox window, click the Matrix control.

b.

Click in the Body section to add a matrix to the report. (You can also drag the Matrix control to the Body section).

The report now contains a matrix with two rows and two columns.

Task 4: Change the Position of the Matrix Control High Level Steps 1.

When you place a matrix control on the Body section, it might not have the correct position. The position of the control can be changed either by dragging the control to the correct position or by changing the control properties.

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

1 - 67

Reporting in Microsoft Dynamics® NAV 2013 Detailed Steps 1.

When you place a matrix control on the Body section, it might not have the correct position. The position of the control can be changed either by dragging the control to the correct position or by changing the control properties. a.

Select any cell in the matrix.

b.

Press Esc. The size handles (white blocks) will appear.

c.

Use the size handles to drag the control to the desired position (by preference in the top left corner). Eventually you can resize the control.

As an alternative for step 3, you can change the position of the control by changing the properties of the matrix. In the Properties window, select the matrix1 control. The properties for the matrix will be displayed (and the matrix control will be selected.)

FIGURE 1.32: REPORT LAYOUT WINDOW

Task 5: Add Dataset Elements for the Items to the Matrix High Level Steps 1.

To add Dataset Elements for the Items to the Matrix.

Detailed Steps 1.

To add Dataset Elements for the Items to the Matrix. a.

1 - 68

In the dataset, select the Item__No__ element and drag it to the first cell on the second row of the matrix control.

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

Module 1: Creating Reports Task 6: Add Dataset Elements for the Locations to the Matrix High Level Steps 1.

To add Dataset Elements for the Locations to the Matrix.

Detailed Steps 1.

To add Dataset Elements for the Locations to the Matrix. a.

In the dataset, select the Item_Ledger_Entry__Location_Code_ element and drag it to the second cell on the first row of the matrix control.

Task 7: Add Totals to the Matrix High Level Steps 1.

To add Totals to the Matrix.

Detailed Steps 1.

To add Totals to the Matrix. a.

In the dataset, select the Item_Ledger_Entry_Quantity element and drag it to the second cell on the second row of the matrix control.

Task 8: Add Formatting to the Matrix High Level Steps 1.

To add Formatting to the Matrix.

Detailed Steps 1.

To add Formatting to the Matrix. a.

Select the text box containing the Item No. field.

b.

In the Properties window, set the BackgroundColor property to Orange.

c.

Select the text box containing the Location Code field.

d.

In the Properties window, set the BackgroundColor property to Dark Blue.

e.

In the Properties window, set the Color property to White.

f.

In the Properties window, set the FontWeight property to Bold.

g.

Select the text box containing the Quantity field.

h.

In the Properties window, in the BorderStyle property collection, set the Left, Right, Top, Bottom and Default properties to Solid.

i.

Save and Exit Visual Studio, import the new RDLC layout in the object, save the object and run it.

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

1 - 69

Reporting in Microsoft Dynamics® NAV 2013 The result will appear similar to the following image.

FIGURE 1.33: MATRIX REPORT PREVIEW WINDOW

1 - 70

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

Module 1: Creating Reports

Lab 1.3: Adding a Chart Scenario As a Project Manager, Prakash is using report 1009, Job Actual to Budget to compare the budgeted and the realized amounts of the different jobs. To have an overall view that includes all jobs, Prakash asks Mort to present the figures in the report by means of a chart. To avoid destroying the original report, Mort will start from report 123456709, which is a copy of the standard report 1009.

Objectives The purpose of this lab is to add a chart to an RDLC report layout. The chart will be based on variables from the dataset (instead of fields). Finally, you will finetune the chart by adding some basic formatting.

Exercise 1: Adding a Chart to an RDLC Report Layout. Exercise Scenario Add a column chart to report 123456709. The chart needs to display the following pricing. •

Total budgeted cost price (Light Coral)



Total realized cost price (Red)



Total budgeted sales price (Light Green)



Total realized sales price (Forest Green)

Task 1: Import Report 123456709 High Level Steps 1.

To import the object in the demonstration database, use the following procedure.

Detailed Steps 1.

To import the object in the demonstration database, use the following procedure. a.

Open the Microsoft Dynamics NAV 2013 demonstration database.

b.

Open the CRONUS International Ltd. demonstration company.

c.

Select Tools, Object Designer to open the Object Designer.

d.

Select File, Import.

e.

Browse to the report R123456709.

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

1 - 71

Reporting in Microsoft Dynamics® NAV 2013 f.

Click OK to start the import.

g.

In the dialog box, choose to open the Import Worksheet window.

h.

In the Action column, verify that the action is set to Create.

i.

Click OK to import the object in the database.

Task 2: Design Report 123456709 High Level Steps 1.

Now, start designing the RDLC report layout.

Detailed Steps 1.

Now, start designing the RDLC report layout. a.

In the Object Designer, open report 123456709, Job Actual to Budget - Chart in design mode.

b.

Select View, Layout to open Microsoft Visual Studio.

Since the report is a copy from the standard report 1009, it already has an RDLC layout.

Task 3: Add a Chart to the Report High Level Steps 1.

The following steps show how to add a chart to the report.

Detailed Steps 1.

1 - 72

The following steps show how to add a chart to the report. a.

Select the Body section by clicking the right grey bar or by selecting the Body option in the Properties window.

b.

Change the height of the Body section by changing its Height property (in the Size property collection). Set the Height property to 18 cm.

c.

Use the vertical scrollbar to visualize the bottom end of the Body section.

d.

In the Toolbox window, select the Chart control.

e.

Click the Body section to insert a Chart control.

f.

The Select Chart Type window opens.

g.

In this window select the Ok button to add a 3D-Column chart to the Body of the report.

h.

Click the Report Data window to display the dataset.

i.

In the dataset, select No_Job and drag it to the Category area below of the chart. When you drag a field from the dataset over the Chart, the areas will display.

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

Module 1: Creating Reports j.

Next, add the fields containing the job totals to the Data area. However, in this case, the totals are displayed using variables. In the dataset, you must select the variables that are used in the sections to display the job totals and drag them to the Data area of the Chart.

k.

Select JobTotalAmt4 and drag it to the Data area.

l.

Select JobTotalAmt5 and drag it to the Data area.

m. Select JobTotalAmt7 and drag it to the Data area. n.

Select JobTotalAmt8 and drag it to the Data area.

o.

Change the size of the chart by changing its properties: set the Height property to 7 cm and set the Width property to 18 cm.

Task 4: Add Formatting to the Chart High Level Steps 1.

Now it is time to add some formatting to the report. Add a chart title, change the names in the legend, change the default colors of the columns and add some effects. The following steps show how to add a title to the chart.

2.

The following steps show how to change the default colors of the columns.

3.

Now, add labels to clarify the elements shown on the X and Y axis of the chart.

4.

Add Visual Effects to the Chart.

Detailed Steps 1.

2.

Now it is time to add some formatting to the report. Add a chart title, change the names in the legend, change the default colors of the columns and add some effects. The following steps show how to add a title to the chart. a.

Right-click the Title control in the chart and select Title Properties.

b.

On the Title Text field, enter Job - Actual vs. Budget.

c.

On the Font tab format the title to Verdana, 12 pt, Bold and Red.

d.

Click OK to close the Properties window.

The following steps show how to change the default colors of the columns. a.

Right-click the field JobTotalAmt4 in the data fields at the top of the chart and select Series Properties.

b.

On the Fill tab, in the Pick Color field: select Light Coral.

c.

Click OK to close the Properties window.

d.

Repeat steps 1 through 3 for the JobTotalAmt5 value. Set the Border and Fill Color to Red.

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

1 - 73

Reporting in Microsoft Dynamics® NAV 2013

3.

4.

e.

Repeat steps 1 through 3 for the JobTotalAmt6 value. Set the Border and Fill Color to Light Green.

f.

Repeat steps 1 through 3 for the JobTotalAmt7 value. Set the Border and Fill Color to Forest Green.

g.

Click OK to close the Chart Properties window.

Now, add labels to clarify the elements shown on the X and Y axis of the chart. a.

Right-click the chart control and select Properties.

b.

On the Legend tab, you can choose to show or hide the legend, and to change the layout and the position of the legend.

c.

Click OK to close the Chart Properties window.

Add Visual Effects to the Chart. a.

Right-click the chart control and select Chart Area Properties.

b.

On the 3-D Options tab, check the enable 3D field. By checking the field, the other options on the tab will be enabled.

c.

Change the Horizontal rotation to 5°.

d.

Change the Wall Thickness to 30 percent.

e.

Change the Inclination to 15.

f.

Click OK to close the Chart Properties window.

g.

Now that the chart is finished, save and exit Visual Studio, import the new RDLC layout in the object, save the object and run it.

The result will appear similar to the following image.

FIGURE 1.34: JOB ACTUAL TO BUDGET REPORT PREVIEW WINDOW

1 - 74

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

Module 1: Creating Reports

Lab 1.4: Using a Gauge Scenario Susan, the Sales Manager, has asked Mort to enhance the existing report Salesperson - Sales Statistics so that the information presented in the report is more visually clear. This report shows amounts for sales, profit, invoice discount, payment discount, and the profit percentage, for each salesperson for a selected period. The report also shows the adjusted profit and adjusted profit percentage, that reflect any changes to the original costs of the items in the sales. Visualizing the information in this report more clearly will ensure that Susan will have a better understanding of the figures and their ratio. As a best practice, Mort will make a copy of the existing report and make the changes to the new report.

Objectives The purpose of this lab is to introduce the Gauge control and learn how to add it to a report.

Exercise 1: Adding a Gauge Control to a Report Exercise Scenario •

Import report 123456710, Salesperson - Sales Statistics- Gauge



Add a gauge to the report



Add dataset elements to the gauge



Add formatting to the gauge

Task 1: Import the Report High Level Steps 1.

To import the object in the demonstration database, use the following procedure.

Detailed Steps 1.

To import the object in the demonstration database, use the following procedure. a.

Open the Microsoft Dynamics NAV 2009 demonstration database.

b.

Open the CRONUS International Ltd. demonstration company.

c.

Select Tools, Object Designer to open the Object Designer.

d.

Select File, Import.

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

1 - 75

Reporting in Microsoft Dynamics® NAV 2013 e.

Browse to the report R123456710.

f.

Click OK to start the import.

g.

In the dialog box, choose to open the Import Worksheet window.

h.

In the Action column, verify that the action is set to Create.

i.

Click OK to import the object in the database.

Task 2: Design the Report High Level Steps 1.

Now start designing the RDLC report layout.

Detailed Steps 1.

Now start designing the RDLC report layout. a.

In the Object Designer, open report 123456710, Salesperson Sales Statistics- Gauge in design mode.

b.

Before you continue, review how the existing report is developed. The report dataset designer shows there are two data items: Salesperson/Purchaser and Cust. Ledger Entry. In the C/AL code view of the report notice the code in the OnAfterGetRecord trigger of the Cust. Ledger Entry. Data item. This is the trigger of the report where the following values are calculated. 

SalesLCY



ProfitLCY



InvDiscLCY



PmtDiscGivenLCY



PmtToleranceLCY



AdjProfit

c.

Now, select View, Layout to open Microsoft Visual Studio.

d.

Since the report is a copy from the standard report 114, it already has an RDLC layout.

Task 3: Add a Gauge to the Report High Level Steps 1.

The following steps show how to add a Gauge to the report.

Detailed Steps 1.

1 - 76

The following steps show how to add a Gauge to the report. a.

Select the last column of the Tablix and right-click.

b.

Select the option: Insert column, right.

c.

A new column is now added to the Tablix.

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

Module 1: Creating Reports d.

Click and select the cell in the detail level of the tablix, in the newly created column.

e.

From the toolbox, double-click the Gauge data region, or drag it to the design surface into the selected cell. The Select a Gauge Type dialog box appears.

f.

Select the Bullet Graph gauge.

g.

Click OK.

h.

Click the gauge to display the Data pane.

i.

In the Data pane, right-click the Linear Pointer 1 box, and in the drop-down menu that opens select Pointer properties.

j.

A popup window opens displaying the Linear Pointer Properties.

k.

In this window, click the Fx button, next to the value field.

l.

In the Expression Designer window type the following expression.

m. =Code.CalcPct(Fields!Cust__Ledger_Entry___Sales__LCY__.Value, Fields!AdjProfit.Value). n.

Click OK.

o.

Click OK.

p.

Now select the cell in which the Gauge is added.

q.

In the Properties window set the Size properties to the following values: Width: 3 cm, Height: 1,4 cm.

r.

Now that the report is finished, save and exit Visual Studio, import the new RDLC layout in the object, save the object and run it.

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

1 - 77

Reporting in Microsoft Dynamics® NAV 2013 The report should now appear similar to the following image.

FIGURE 1.35: REPORT WITH GAUGE

1 - 78

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

Module 1: Creating Reports

Module Review Module Review and Takeaways This module explained the architecture of Microsoft Dynamics NAV 2013 and the Visual Studio integrated development environment. It also examined the integration between the Report Dataset Designer and the Visual Studio Report Designer in relation to report creation, report execution, dataset generation, sorting and filtering data. Additionally, the module discussed some of the most frequently used properties and functions.

Test Your Knowledge Test your knowledge with the following questions. 1.

Which report items are not available in the Visual Studio Report Designer? ( ) Text box ( ) Chart ( ) Gauge ( ) Drop-down list

2.

Which property can be set on a column to influence the name of the corresponding element in the dataset? ( ) DataSetName ( ) Name ( ) DataSetSourceExpr ( ) DataSetID

3.

What does RDL stand for? ( ) Report Dataset Language ( ) Report Definition Language ( ) Report Design Language ( ) Report Data Language

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

1 - 79

Reporting in Microsoft Dynamics® NAV 2013 4.

Which export formats are offered by the report viewer control? ( ) XML ( ) PDF ( ) Microsoft Office Excel ( ) HTML

5.

Which data item properties are supported by the report designer in the Microsoft Dynamics NAV 2013 ? ( ) DataItemTableView ( ) DataItemLink ( ) NewPagePerRecord ( ) TotalFields

1 - 80

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

Module 1: Creating Reports

Test Your Knowledge Solutions Module Review and Takeaways 1.

Which report items are not available in the Visual Studio Report Designer? ( ) Text box ( ) Chart ( ) Gauge (√) Drop-down list

2.

Which property can be set on a column to influence the name of the corresponding element in the dataset? ( ) DataSetName (√) Name ( ) DataSetSourceExpr ( ) DataSetID

3.

What does RDL stand for? ( ) Report Dataset Language (√) Report Definition Language ( ) Report Design Language ( ) Report Data Language

4.

Which export formats are offered by the report viewer control? ( ) XML (√) PDF ( ) Microsoft Office Excel ( ) HTML

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

1 - 81

Reporting in Microsoft Dynamics® NAV 2013 5.

Which data item properties are supported by the report designer in the Microsoft Dynamics NAV 2013 ? (√) DataItemTableView ( ) DataItemLink ( ) NewPagePerRecord ( ) TotalFields

1 - 82

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

MODULE 2: INTERACTIVE FEATURES Module Overview The previous module introduced the new architecture of Microsoft Dynamics® NAV 2013 and it also provided a detailed explanation for the anatomy of a report. You also learned how to create a basic report. The previous module introduced the new reporting solution, and you created a basic report and used the dataset to implement currency and date formatting. Now you will learn more about the features that are offered in Reporting Services. In addition, in this module you will discover the interactive features from the new solution. You will learn to work with different types of headers and footers, how to define interactive sorting, how to apply visibility options, how to use images and how to add extra navigation features such as a document map. In environments that support interactivity, reports can include a variety of features that provide interactivity to users. Users can influence the appearance of a report and the data it contains by typing or selecting a value for a filter before running the report. A user can show or hide items in a report and click links that go to other reports, webpages and pages. Visual Studio Report Designer also provides a document map, which acts like a table of contents. A user can click items in the document map to jump to areas within a report. Formatting the items in your report makes the report look more attractive and enhances its readability. You can format the text boxes and individual items within the text boxes, the images, the expressions, and the data while in design mode. You can design a report so that different styles are applied to report items or properties based on the data in the report. You can build conditional expressions using any feature supported by expressions, including a built-in report and aggregate functions, built-in collections, and custom code. This module will explain some of the interactive features for the reports in Dynamics NAV.

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

2-1

Reporting in Microsoft Dynamics® NAV 2013 Objectives The objectives are:

2-2



Explain when to use headers and footers and how to add or delete a header or footer section.



Explain the difference between Print Preview and Print Layout.



Describe the visibility options for the reports and how to use them.



Explain interactive sorting and how to implement it.



Explain how document maps work and how to add them to a report.

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

Module 2: Interactive Features

Working with Headers and Footers A report can have a header and a footer that will be visible at the top and bottom of all the pages. The page header and footer can contain static content, but they are more commonly used to display varying content such as page numbers or information about the contents of a page. They can also contain expressions, static text, images, lines, rectangles, borders, background color, and background images. It is important to have a good understanding of the purpose, capabilities and limitations of headers and footers.

Headers and Footers The Report Definition Language for Clients applications (RDLC) 2008 specification supports three section types: a page header, a body and page footer. No additional sections can be added. When you create a new report and open it in Visual Studio Report Designer, only the Body section is displayed. The Page Header and Page Footer sections must be manually added to the report. A report can contain a header and footer that run along the top and bottom of each page, respectively. By default, page headers and footers are not part of a report. After you create a page header or footer, it is displayed on each report page. The next paragraphs explain how to add, design or delete these sections.

Page Header and Footer The page header is the first section that will print when a report is run. Typically, a header contains some general information, such as: •

Report title



User who printed the report



Date and time information



Page number and or number of pages



Company logo

A report can contain a page header and page footer that run along the top and bottom of each page, respectively. After you add a header or footer, you can selectively hide it on the first and last pages of a report using the properties: PrintOnFirstPage and PrintOnLastPage.

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

2-3

Reporting in Microsoft Dynamics® NAV 2013 Note: If you add paging information to a header, it might not always be correct when you run the report in preview mode, especially if the report has a long body section. If you print the report to a printer, the information will be correct. For more information, refer to the Print Preview and Print Layout section. Design a Header/Footer Section If no header or footer is defined for the report in Visual Studio, only the body section will appear. Headers and footers can be designed the same way as body sections. To add a control to a header section, grab the control in the Visual Studio Toolbox and drag it to the header section. Alternatively, select the control in the Toolbox, then click the header section to insert the control. You can add the following controls to a header and footer: •

Text box



Line



Rectangle



Image

You cannot add data region controls (table, matrix, chart, Gauge or list) to a header or footer. You can use the header or footer properties to add borders, background images, or colors, or to adjust the width of the header. To access the Header or Footer properties, right-click the corresponding section and select Properties. Delete a Page Header or Page Footer You can easily remove headers and footers by using the same toggle items that you use to add a header or footer. By removing a header or footer section, you are deleting it from the report. Any controls that you previously added to the section will be deleted as well. If you add the header or footer section again, the controls will not be added again automatically. To delete an existing page header or page footer section, select Report, and then in the menu, choose Remove Page Header or Remove Page Footer. Alternatively, you can right-click the page header or page footer section, and then from the menu, choose Remove Page Header or Remove Page Footer.

2-4

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

Module 2: Interactive Features Finally, you can also delete a page header or footer section by right-clicking either the report selection menu or the design surface and then from the menu, choose Page Header or Page Footer.

FIGURE 2.1: DELETE A PAGE HEADER OR FOOTER FROM THE DESIGN SURFACE AREA WINDOW A Default Page Header, Footer and Body Section for All Reports If you want to design a basic company layout for all reports, you can change the standard Visual Studio solution template that is used as a base for all new reports. To do this, open the solution that is installed under C:\Program Files\Microsoft Dynamics NAV\70\RoleTailored Client\ReportLayout. This is the default location for the solution, but you can change it if this is required. Change the design to fit your needs (you can include embedded images) and save the files. The modified solution is used as a template for all new reports that are created from scratch in the Visual Studio Report Designer. Note: Remember to copy the modified solution to all clients that will be used to design reports.

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

2-5

Reporting in Microsoft Dynamics® NAV 2013 Data Fields in a Page Header and Page Footer The RDLC 2005 specification included a serious limitation: data fields could be not added to a Page Header or Footer. Although in design mode, you could add a text box to a Page Header, drag a field from the dataset to it, and import the RDLC data in the report, you could not save the report in Report Designer. Instead an error message displayed “Error while validating RDL content: The Value expression for the textbox ‘X’ refers to a field. Fields cannot be used in page headers or footers. “ Although this is a serious limitation, a scenario exists to work around this that can still be found in various standard reports. The scenario made use of the ReportItems collection. The ReportItems built-in collection is the set of text boxes from report body. The ReportItems collection includes text boxes that are in the current scope of a page header, page footer, or report body. Typically, a field from the dataset is added to the body section of the RDLC layout, as a separate text box or as a table column. Then the ReportItems collection is used on the page header to retrieve the contents of the invisible text box in the Page Header section. Because tables might span several pages, the variable (and its contents) will move and be available. However, when the report body contains multiple tables, like in most document reports, another workaround is required. This makes use of a global variable that stores the data to be displayed in the page header and two functions: GetData and SetData. The SetData function stores information in the global variable and the GetData retrieves information from the variable. This scenario is no longer required in Microsoft Dynamics NAV 2013. The RDLC 2008 specification now allows for data bound items to be placed in page headers and footers. As a result, the steps mentioned here are now obsolete. When you upgrade a report from Microsoft Dynamics NAV 2009 to Microsoft Dynamics NAV 2013 the scenario that is implemented in the ‘old’ report will be copied to the upgraded report, although it is no longer required. For more information about the report upgrade process, see module: Upgrade Reports of this course.

2-6

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

Module 2: Interactive Features Demonstration: Add a Page Header or Footer Demonstration Steps 1.

2.

Mort has to add a report header to his reports. To do this, he adds a Page Header section to the report. a.

Open the report in Visual Studio.

b.

In this case, use report 123456700. If the Object Designer isn’t already open, open it using the menu: Tools, Object Designer. Select Reports in the Object Designer and Design report 123456700. In the Report Dataset Designer select View, Layout to open Visual Studio.

c.

To add a Page Header section, from the menu, select Report, Add Page Header.

d.

To add a Page Footer section, from the menu, select Report, Add Page Footer.

As an alternative solution, you can use the following procedure to add the Page Header or Page Footer section. a.

Right-click either the report selection handle or the report design surface.

b.

From the menu, select Add Page Header and/or Add Page Footer.

A header and/or footer will now be added to the report. In both menus, Page Header and Page Footer are toggle items; they can be used both for adding and deleting the section.

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

2-7

Reporting in Microsoft Dynamics® NAV 2013 3.

As a result the report now contains a page header and footer.

FIGURE 2.2: A REPORT WITH A PAGE HEADER AND PAGE FOOTER WINDOW

Table Header and Footer When you drag and drop a field from the Report Dataset onto the Report Body in Visual Studio Report Designer, a text box is automatically created. When you run the report, only the first value of the field in the text box is shown. For a report to show multiple records from the dataset, a data region such as a tablix is needed. A tablix is a data region control. Unlike a line or a rectangle, a tablix data region (and more in particular the detail row) is used to loop through the records and display data. Additionally, the detail row is designed only once and then repeated for all records in the recordset. You can add multiple tablix data regions to the body section. Use the Tablix data region to display fields from a dataset either as detail data or as grouped data in a grid or free-form layout. There are three templates for a Tablix data region that you can add directly from the Toolbox:

2-8



Table



Matrix



List

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

Module 2: Interactive Features A table can have three types of rows. Row Type Table Header

Description By default, the table header is printed once for each table. This is a typical place to put captions. If you drag an item containing text from your dataset into a header, the environment automatically adds “First” to it. “First” means that it will show the first value in the dataset, as opposed to looping through each record in the dataset. Tables can have multiple table headers.

Table Details

The detail row is used to display data from the dataset. It can be compared to the body section of the classic Section Designer. Tables can have multiple detail rows.

Table Footer

The table footer is printed once for each table. It is a typical place to insert subtotals or grand totals. If you drag an item containing a numerical value from your dataset into a footer, the environment automatically adds “Sum” to it, and the report will print the total from the report. Tables can have multiple footers.

By combining table headers and footers with group header and footers, you can print any total you want. When you add a table header and footer, two new rows are added to the table (one immediately above the detail row, and one immediately below). These are the table header and the table footer rows. If group headers and or footers are defined for the table, the table header will be inserted above all group headers and the table footer will appear after all group footers.

FIGURE 2.3: HEADERS AND FOOTERS IN A TABLE CONTROL WINDOW

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

2-9

Reporting in Microsoft Dynamics® NAV 2013 Design a Table Header or Table Footer To add data to a group header or footer, select an element in the dataset and drag it to a cell in the table header or footer. (You can obtain the same result by setting a value for the Value property of the header or footer cell.) You can also take values from cells in other rows. If you add a decimal value to the header or footer, Visual Studio Report Designer will automatically add the Sum operator to the field value. As a result, the grand total for the table will display. By doing this, you can have totals calculated, without having to define any keys (with SumIndexFields) or set sorting, grouping and totaling properties in Microsoft Dynamics NAV. Delete a Table Header or Table Footer To delete a table header and the corresponding footer, follow these steps. 1.

Right-click the row handle of the correct table header or footer.

2.

Select Delete Rows.

Only the selected row will be deleted.

Demonstration: Add a Table Header or Footer Mort will add a table header and a table footer row to display the field captions.

Demonstration Steps 1.

To add a header row in a table: a.

Select a detail row in a table.

b.

Right-click the row handle and select Insert Row, Above/Below.

Repeat Headers and Footers on New Pages In the Visual Studio Report Designer, you can set the RepeatColumnHeaders in the Tablix Properties window. 1.

Select any cell in the table, then press ESC. (If you want, you can obtain the same result by selecting the table control in the Properties window.)

2.

Right-click the grey dotted table border and select Properties.

3.

Set the RepeatColumnHeaders property.

4.

Click OK to apply the changes and close the Table Properties window.

Changing the Table Properties window will cause the properties of the underlying table and the individual table rows to change.

2 - 10

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

Module 2: Interactive Features Freezing the Header Rows If you want the header rows to remain visible when scrolling in a report, you can also define this in the Table Properties window. When you export the report to Excel, the worksheet window in Excel will be split in multiple resizable panes. The Page Header section will be put in one pane (and remain visible) while the body section will be put in another.

Colors in Headers and Footers Reports can be printed in color. Using Colors in Headers and Footers To fine-tune the layout and to acquire a better view on the contents of the report, you can work with colors. You can use colors to emphasize specific pieces of data and also to reflect the structure of the content. For example, you can have the Unit Price printed in blue and the Unit Cost in yellow, or you can print a specific group header row (and the corresponding group footer) with a green background color, so you can easily distinguish the logical structure of the report (everything between the two green rows is a logical group). You can define the colors for each individual control by setting the BackgroundColor and Color properties. The Color property defines the text color; the BackgroundColor property determines the background color of the control. By default, the BackgroundColor property is set to Transparent and the Color is set to Black. In Visual Studio Report Designer, you can also set the BackgroundColor and Color properties for multiple controls at the same time. If you select multiple individual controls or an entire table row or column, you can change the background and text color for all these controls by setting both properties. In addition to the BackgroundColor and Color properties, there are a number of other properties (TextAlign, CanGrow, CanShrink) and property collections (Font, Padding, BorderColor, BorderStyle, BorderWidth, and so on) that can be defined for multiple controls at the same time (provided that the properties are common to all selected controls).

Adding Texts to Headers and Footers As you work with headers and footers and subtotals on different levels, it might be interesting to print extra "labels" explaining the data printed in the report. For example, next to each subtotal you can print text such as "Total for Customer 10000", "Total for Country AT," or you can add the name of the customer to a separate cell in the "Customer No." group header. Although additional texts can be a fixed text, an element from the dataset, or a combination of both, its recommended to use Labels instead.

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

2 - 11

Reporting in Microsoft Dynamics® NAV 2013 These labels can be created in the Report Label Designer. By creating these labels in the Report Label Designer an advantage is the Multi Language functionality by using the CaptionML property of the label. To print text in a specific cell, select the cell and change its Value property. It is recommended to use the Expression window, because you can enter text and select variables, functions, and so on from a list. Remember that the width of the cell containing the text depends on the size of the column in the table detail row.

Demonstration: Enter Custom Text in a Merged Cell If you want to include longer texts in a header or footer row, you might have to merge the cells from the row before you insert the text. To merge cells, select the necessary cells, right-click any of the selected cells and choose Merge Cells. If you want to split the cells, right-click the merged cell and select Split Cell. Finally, you can change the alignment of the texts by setting the individual cell properties. You might also want to have the customer name printed next to the customer number. To do this, merge the necessary cells (if necessary) then drag the Customer Name from the dataset to the right cell in the group header.

Demonstration Steps 1.

2.

2 - 12

To merge a cell, follow these steps. a.

Open Report 123456700 in Visual Studio.

b.

Select the column header for the fifth row and right click.

c.

Select Insert Column, Left.

d.

Repeat the last two steps to insert another new column.

e.

In the Detail row of the table, select the two textboxes next to each other (on the fifth and sixth column).

f.

Right click and select: Merge Cells.

To enter custom text in the merged cell, follow these steps. a.

Select the merged cell.

b.

Right-click the merged cell, and select . The Expression window will appear.

c.

In the drop-down list box the current cell value―if any―is displayed. If the cell is empty, only the equal (=) sign will be displayed. Make sure not to delete the equal (=) sign. It indicates that the cell value is an expression and not a fixed text. If you remove the equal (=) sign, all text that you enter in the expression window will be displayed as plain text.

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

Module 2: Interactive Features d.

In the drop-down list box, you can now compose an expression consisting of fixed texts and/or variables, functions, dataset elements, and so on. Fixed text should be placed between double quotes. To use a dataset element, function, variable, and more, select the element in the corresponding category and doubleclick it. If the text consists of multiple parts, you can use the ampersand (&) to concatenate the parts.

e.

Click OK to close the Expression window. The expression will be copied to the Value property.

Demonstration: Add Labels to a Report The management of Cronus has asked Mort to modify the Inventory List report. A column needs to be added that shows the Inventory Quantity and a total for this column must be added at the bottom of the list.

Demonstration Steps 1.

2.

3.

Open the report and add the Inventory field to the dataset. a.

Open the Object Designer.

b.

Import report 123456711 Inventory – List2 and click Design.

c.

In the Report Dataset Designer add a new row at the end.

d.

Select the Field Menu button.

e.

The Field Menu window opens.

f.

In the Field Menu window select the Inventory Field and click the Ok button.

g.

The Item.Inventory field is added to the Report Dataset Designer.

h.

Select the Include Caption for the newly added field.

Add a label for Total. a.

In the Report Dataset Designer, select the menu and open: View, Labels.

b.

The Report Label Designer window opens.

c.

Add a new line in the Report Label Designer and in the column named Name type Total.

d.

In the column named Caption type Total.

e.

Close the Report Label Designer.

Add the Inventory field and Total Label to the report. a.

Select View, Layout in the menu.

b.

The Visual Studio Report Designer opens.

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

2 - 13

Reporting in Microsoft Dynamics® NAV 2013 c.

In the Tablix, right click the last column header and select Insert Column, Right.

d.

A new column is now added to the table.

e.

Right click the text box in the detail row of the last column and select: Expression.

f.

The expression Designer window opens.

g.

Type the following expression: =Fields!Inventory_Item.Value

h.

In the properties of the field set the Format property to: =Fields!Inventory_ItemFormat.Value

i.

Close the Expression Editor window.

j.

In the header row of the last column, open the expression editor and type the following expression: =Parameters!Inventory_ItemCaption.Value

k.

In the Row Groups window, select the Table1_Details_Group and click: Add Total, After as shown in the next screenshot:

FIGURE 2.4: ADD A ROW TOTAL AFTER WINDOW A new row is added to the table. l.

In the last field of the last row enter the following expression: =Sum(Fields!Inventory_Item.Value)

m. In the properties of the field, set the property FontWeight to Bold. n.

In the properties of the field set the Format property to: =Fields!Inventory_ItemFormat.Value

o.

In the textbox to the left of the current textbox type the following expression: =Parameters!Total.Value

2 - 14

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

Module 2: Interactive Features

4.

p.

In the properties of the field, set the property FontWeight to Bold.

q.

Select the last row of the report and set the BackGroundColor property to: No Color.

Save and Run the report. a.

Close the Visual Studio Report Designer.

b.

When you are asked to save, click Yes.

c.

Close the Report Dataset Designer and when you are asked to save, click Yes.

d.

Select the report in the Object Designer and click Run.

e.

Scroll to the last page of the report.

The result will look similar to this:

FIGURE 2.5: INVENTORY LIST REPORT WITH TOTAL WINDOW

Report Header and Footer A report can contain a header and footer that run along the top and bottom of each page, respectively. Headers and footers can contain expressions, static text, images, lines, rectangles, borders, background color, and background images. Expressions include dataset field references for reports with exactly one dataset and aggregate function calls that include the dataset as a scope. By default, page headers and footers are not part of a report. After you create a page header or footer, it is displayed on each report page.

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

2 - 15

Reporting in Microsoft Dynamics® NAV 2013 The Report Header section generally contains the report title and other information you want to appear only at the beginning of the report. For example charts and cross-tabs placed in this section contain data for the entire report. Objects placed in the Report Header section print once, at the beginning of the report. Page headers and footers are not the same as report headers and footers. Reports do not have a special report header or report footer area. A report header consists of the report items that are placed at the top of the report body on the report design surface. They appear only once as the first content in the report. Report footer consists of report items that are placed at the bottom of the report body. This section is used to contain information you want to appear only once at the end of the report, such as grand totals. They appear only once as the last content in the report. The difference between a page header/footer and a report header/footer is illustrated in the following image.

FIGURE 2.6: PAGE HEADER AND REPORT HEADER WINDOW

Grouping Group Header and Footer In a report, you can use groups to organize data on the report and/or to calculate aggregate summaries. Understanding how to define groups and use group features will help you design reports that are more concise and communicate summarized data in a more compact format.

2 - 16

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

Module 2: Interactive Features A group can be considered as a named set of data from the dataset that is bound to a data region. Basically, a group organizes a view of the report dataset. All groups in a data region specify different views of the report dataset. To help visualize what a group is, the following figure shows the Tablix data region. In this figure, the row groups categorize the dataset by city and salesperson and the column groups categorize the dataset by month and year.

FIGURE 2.7: GROUPS IN A TABLIX DATA REGION WINDOW Groups are internally organized as members of one or more hierarchies. A group hierarchy has parent/child groups that are nested and can have adjacent groups. The Tablix data region includes a row group hierarchy and a column group hierarchy. Data associated with row group members expands horizontally across the page and data associated with column group members expands vertically down the page. The Grouping pane displays row group and column group members for the currently selected Tablix data region on the design surface. For example, the Grouping pane of the Tablix data region mentioned here is shown in the following figure.

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

2 - 17

Reporting in Microsoft Dynamics® NAV 2013

FIGURE 2.8: TABLIX GROUPING PANE The Row Groups pane and the Column Groups pane display a hierarchical view for all parent groups, child groups, and adjacent groups. A child group appears indented under its parent group. An adjacent group appears at the same indent level as its sibling groups. Typically, you add groups to a data region when you want to display your data in a visual hierarchy, align multiple data regions to show different views of the same data, or to calculate totals. After the data is grouped, you can sort the data within each group in ascending or descending order to make data easier to locate. When you add a row or column to a table, matrix, or list, you can specify whether to add the row or column inside or outside a group. A row or column that is outside a group can serve as a group header or group footer, depending on where you position the row or column. When the data region renders in the report, you can set properties that help keep the row or column with the group.

Demonstration: Add a Parent or Child Row or Column Group to a Tablix To group the data and display totals in the report, Mort will use groups.

Demonstration Steps 1.

2 - 18

The following example shows how to add a tablix control in a report. a.

Open the Object Designer.

b.

Import report R123456714.fob, confirm and click Design.

c.

Click View, Layout to open Visual Studio Report Designer.

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

Module 2: Interactive Features d.

Drag a field from the Report Data pane to the Row Groups pane or the Column Groups pane. For example use the field City_Customer.

e.

Drop the field above or below the group hierarchy using the guide bar to place the group as a parent group or a child group to an existing group.

The group is added with a default name, group expression, and a sort expression that is based on the field name as shown in the following screenshot:

FIGURE 2.9: ADD ROW GROUP WINDOW

Demonstration: Add an Adjacent Row or Column Group to a Tablix To group the sales data by product group and by territory, Mort will add an adjacent group to the report.

Demonstration Steps 1.

To add an adjacent group to the report: a.

Open the Object Designer.

b.

Select report R123456714.fob, click Design.

c.

Click View, Layout to open Visual Studio Report Designer.

d.

In the Grouping pane, right-click a group that is a peer to the group that you want to add. Click Add Group, and then click Adjacent Before or Adjacent After to specify where to add the group. The Tablix Group dialog box opens.

e.

In Group by expression, select a field,for example. [CurrencyCode_Customer] or click the expression button (fx) to create an expression.

f.

Click OK.

g.

Select the group properties of the newly added group.

h.

Set the Name to CurrencyCode_Customer.

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

2 - 19

Reporting in Microsoft Dynamics® NAV 2013 The steps described here above are visualized in the following diagram:

FIGURE 2.10: ADD ADJACENT GROUP WINDOW Mort has now added a new group to the Tablix data region on the design surface.

Demonstration: Edit a Row or Column Group in a Tablix Data Region Mort made an error when he added a group to the Tablix. To correct it he will now edit the group settings.

Demonstration Steps 1.

2 - 20

To edit the group settings: a.

On the report design surface, click anywhere in the Tablix data region to select it. The Grouping pane displays the row and column groups.

b.

Right-click the group and then click Group Properties.

c.

In Name, type the name of the group, if you want to change it.

d.

In Group expressions, type or select a simple expression, or click the Expression (fx) button to create a group expression.

e.

Click Add to create additional expressions. All expressions you specify are combined using a logical AND to specify data for this group.

f.

(Optional) Click Page Breaks to set page break options.

g.

(Optional) Click Sorting to select or type expressions that specify the sort order for values in the group.

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

Module 2: Interactive Features h.

(Optional) Click Visibility to select the visibility options for the item.

i.

(Optional) Click Filters to set filters for this group.

j.

(Optional) Click Variables to define variables that are scoped to this group and are accessible from any child groups.

k.

Click OK.

Demonstration: Delete a Group from a Tablix Mort is asked to modify the layout of an existing report, to remove a group.

Demonstration Steps 1.

The following example shows how to remove a Group from a Tablix control. a.

In the Grouping pane, right-click the group, and then click Delete Group.

b.

In the Delete Group dialog box, select one of the following options:

c.

i.

Delete group and related rows and columns Choose this option to delete the group definition and all related rows that display group data. For the details group, if the same row belongs to both detail and group data, only the detail data rows are deleted.

ii.

Delete group only Choose this option to keep the structure of the Tablix data region the same and delete only the group definition.

Click OK.

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

2 - 21

Reporting in Microsoft Dynamics® NAV 2013 Using a Stepped Report A stepped report shows detail rows or child groups indented under a parent group in the same column, as shown in the following example.

FIGURE 2.11: STEPPED REPORT WINDOW Traditional table reports place the parent group in an adjacent column on the report. The new Tablix data region enables you to add a group and detail rows or child groups to the same column. To differentiate the group rows from the detail or child group rows, you can apply formatting such as font color, or you can indent the detail rows.

Demonstration: Create a Stepped Report Demonstration Steps 1.

2 - 22

Add a parent group to your report. a.

Open the Object Designer.

b.

Import report R123456715.fob, confirm and click Design.

c.

Click View, Layout to open Visual Studio Report Designer.

d.

Click anywhere in the table to select it. The Grouping pane displays the Details group in the Row Groups pane.

e.

In the Grouping Pane, right-click the Details Group, point to Add Group, and then click Parent Group.

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

Module 2: Interactive Features f.

In the Tablix Group dialog box, type or select a group expression from the drop-down list, for example [ServiceItemGroup_Item]. The drop-down list displays the simple field expressions that are available in the Report Data pane.

g.

Select Add group header. This option adds a static row above the group for the group label and group totals.

h.

Click OK.

You now have a basic tabular report. When it is rendered, you see one column with the group instance value, and one or more columns with grouped detail data. 2.

For a stepped report, you do not need the first column that shows the group instance. Instead, follow these steps a.

Copy the value in the group header cell, which is [ServiceItemGroup_Item].

b.

To remove the group column, right-click the group column or cell, and click Delete.

c.

Paste [ServiceItemGroup_Item] in the first text box in the second row.

d.

Change the expression of the first textbox on the first row to [@ServiceItemGroup_ItemCaption].

e.

The following figure shows what the data region might look like on the design surface.

To indent the detail rows under the group header row in the same column, change the padding of the detail data cell. f.

Select the cell with the detail field that you want to indent. In this example it’s the textbox containing [No_Item].

g.

In the Properties pane, expand the properties for Padding.

h.

For Left, type a new padding value, such as .5in. Padding indents the text in the cell by the value you specify. The default padding is b points. Valid values for the Padding properties are zero or a positive number, followed by a size designator.

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

2 - 23

Reporting in Microsoft Dynamics® NAV 2013 Size designators are: in

Inches (1 inch = 2.54 centimeters)

cm

Centimeters

mm

Millimeters

pt

Points (1 point = 1/72 inch)

pc

Picas (1 pica = 12 points)

Your data region will look similar to the following example.

FIGURE 2.13: DATA REGION FOR STEPPED REPORT LAYOUT The report displays the group with indented levels for the child group values.

Demonstration: Create a Report With Multiple Groupings Mort is aked to create a report to display customers and their transaction details.

Demonstration Steps 1.

2 - 24

To create the report a.

Open the Object Designer.

b.

Click the Report button.

c.

Click New to create a new report.

d.

In the Report Dataset Designer, select the first line, and in the Data Type field, select Data Item; enter Customer (or type 18) in the Data Source field. This means that our report will be built on the basis of the Customer table the data from which will be retrieved and displayed at the top level of the report.

e.

On the next row, in the Data Type field, select Data Item; type 21 to insert the Cust. Ledger Entry table in the Data Source field.

f.

The second data source is automatically indented under the first one. This means that for each customer record, the Customer Ledger Entry table will be looped through. You can adjust the indent at any time by clicking the arrow left or arrow right button in the bottom right corner.

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

Module 2: Interactive Features g.

On the next row, in the Data Type field, select Data Item option; enter 379 to insert the Detailed Cust. Ledg. Entry table in the Data Source field.

h.

Note that the third data source is automatically indented under the second one. The third data source is automatically indented under the second one.

i.

On the next row, in the Data Type field, select Data Item option; type 36 to insert the Sales Header table in the Data Source field.

j.

We need this data item to be indented under the Customer table (on the same level as the Cust. Ledger Entry table). To correct the indentation, use the arrow left and arrow right buttons in the bottom right corner of the designer.

k.

Now the report structure should look as shown in the screenshot below.

FIGURE 2.14: REPORT DATASET DESIGNER WINDOW l.

Click File, Save As and enter 123456710 for the report ID and CustomerDetails for the report name.

m. Click OK. n.

Do not close the Report Dataset Designer.

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

2 - 25

Reporting in Microsoft Dynamics® NAV 2013 2.

Update the report data item properties. a.

Select the first row with the Customer data source and press Shift+F4.

b.

Change the data item properties as shown and close the Properties window to save the values.

FIGURE 2.15: DATA ITEM PROPERTIES WINDOW c.

2 - 26

In the Report Dataset Designer, select the second row with the Cust. Ledger Entry data source.

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

Module 2: Interactive Features d.

Change the data item properties as shown and close the Properties window to save the values.

FIGURE 2.16: DATAITEMTABLEVIEW WINDOW e.

In the Report Dataset Designer, select the third row with the Detailed Cust. Ledger Entry data source.

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

2 - 27

Reporting in Microsoft Dynamics® NAV 2013 f.

Change the data item properties as shown and close the Properties window to save the values.

FIGURE 2.17: DATA ITEM LINK WINDOW

2 - 28

g.

In the Report Dataset Designer, select the fourth row with the Sales Header data source.

h.

Change the data item properties as shown and close the Properties window to save the values.

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

Module 2: Interactive Features

FIGURE 2.18: INDENTATION WINDOW 3.

Add fields to the report. a.

In the Report Dataset Designer, select the first row with the Customer data item and click View, Field Menu.

b.

In the Field Menu window, holding the Ctrl key, select the following fields: No., Name, Address, Phone No., and E-Mail, and then click OK.

c.

Click Yes on the confirmation message to add the selected fields to the Report Dataset Designer.

FIGURE 2.19: ADD FIELDS FOR CUSTOMER WINDOW

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

2 - 29

Reporting in Microsoft Dynamics® NAV 2013 d.

The Name values in the Report Dataset designer must be short and Unique. Change the names of the added fields as shown:

FIGURE 2.20: FIELD NAME WINDOW e.

In the Report Dataset Designer, select the row with the Cust. Ledger Entry data item and click View, Field Menu.

f.

In the Field Menu window, holding the Ctrl key, select the following fields: Entry No., Customer No., Posting Date, Document Type, Document No., Description, Currency Code, Amount, Original Amt. (LCY), and Remaining Amt. (LCY), and then click OK.

g.

Click Yes on the confirmation message to add the selected fields to the Report Dataset Designer.

h.

Change the values in the Name column as shown:

FIGURE 2.21: CHANGED FIELD NAMES WINDOW

2 - 30

i.

In the Report Dataset Designer, select the row with the Detailed Cust. Ledger Entry data item and click View, Field Menu.

j.

In the Field Menu window, holding the Ctrl key, select the following fields: Entry No., Entry Type, Posting Date, Document Type, Document No., Amount (LCY), Transaction No., Journal Batch Name, Debit Amount (LCY), Credit Amount (LCY), and then click OK.

k.

Click Yes on the confirmation message to add the selected fields to the Report Dataset Designer.

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

Module 2: Interactive Features l.

Change the values in the Name column as shown:

FIGURE 2.22: UPDATED FIELD NAMES WINDOW m. In the Report Dataset Designer, select the row with the Sales Header data item and click View, Field Menu. n.

In the Field Menu window, holding the Ctrl key, select the following fields: Document Type, No., Posting Date, Prices Including VAT, and Amount, and then click OK.

o.

Click Yes on the confirmation message to add the selected fields to the Report Dataset Designer.

p.

Change the values in the Name column as shown:

FIGURE 2.23: CHANGE FIELD NAMES WINDOW q.

For each created row of the Column type, press Shift+F4 and, in the Properties window, set the IncludeCaption property to Yes.

Press Ctrl+S to save the report and click OK on the confirmation message. Do not close the Report Dataset Designer. 4.

Add labels to the report. a.

Click View, Labels.

b.

In the Report Label Designer window, enter the following two labels and their captions:

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

2 - 31

Reporting in Microsoft Dynamics® NAV 2013

FIGURE 2.24: LABEL DESINGER WINDOW c.

Close the Report Label Designer window.

d. Close the Report Dataset Designer window and click Yes on the confirmation message to save changes. e.

Run the Report.

f.

Observe the request page of the report.

FIGURE 2.25: REQUEST PAGE WINDOW g.

2 - 32

The request page contains only one Customer filter tab with the possibility to add other filters from the Customer table.

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

Module 2: Interactive Features If you click Preview, the report will display a blank page because there is no layout for the report created yet. 5.

Arrange the list of tasks the report should perform. a.

Functional requirements: i.

For each customer, the report should show the list of ledger entries and for each ledger entry, the report should show the list of detailed ledger entries.

ii.

After the ledger entries, the report should list the sales document headers for this customer with the basic information.

iii. A check mark in the Show Customer Details field should enable the functionality of displaying the customer’s contact details next to the customer number and name. iv. Each section of data for a single customer should begin on a new page. v.

Report should display the current filters, company name, and company logo in the header on every page.

vi. The Amount field from the Cust. Ledger Entry table should be totaled for each customer. b.

Design requirements: vii. Report should have a landscape orientation. viii. The Options tab with a Show Customer Details check box must be added on the request page to toggle the level of transaction detail to display. ix. The report should skip the data sections if there are no records to display (for example, no sales documents for a customer). x.

The report layout should change depending on the value in the Show Customer Details check box on the request page.

xi. A ShowCustomerDetails variable must be added and passed to the RDLC data set. xii. Amount fields must not display zero values. 6.

Create the basic RDLC layout. a.

Open report 123456710 in design mode.

b.

In the menu bar, click View, Layout.

c.

The RDLC report layout is displayed in Microsoft Visual Studio. The layout is blank.

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

2 - 33

Reporting in Microsoft Dynamics® NAV 2013 d.

Enable the report header by right-clicking anywhere outside of the report (in the grey area) and then clicking Add Page Header in the context menu.

e.

Set up a landscape orientation of the report and define the size of the visible area.

f.

Right-click anywhere outside of the report (in the grey area) and then click Report Properties.

g.

In the Report Properties window, on the Page Setup tab, in the Paper size section, select the Landscape orientation icon. Note, that the Width and Height properties will be changed accordingly.

h.

Click OK to close the Report Properties window.

i.

Place a list into the body section to group the report data.

j.

Click View, Toolbox (if not already shown). In the left-most corner next to the report, click the Toolbox tab to display the Toolbox pane, and then select the List control.

k.

Click the Body section of the report to place the List control into this section to store all the report data.

l.

Move the control to the top of the section and resize it to cover the whole page width.

m. Change the background color for the control to make it visible (for the development time only): n.

Right-click somewhere in the middle of the List control, and then click Rectangle Properties.

o.

In the Rectangle Properties window, browse to the Fill section.

p.

Set the Fill color property to an arbitrary color and click OK.

FIGURE 2.26: ARBITRARY COLOR WINDOW Changing colors of all report elements will help you to identify them on the report preview. It is recommended to set different color properties for table header and detail rows, text boxes, and so on.

2 - 34

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

Module 2: Interactive Features 7.

Set up the list properties. a.

In the inserted list, right-click on the selected row (the shaded border to the left of the selected row) and then click Tablix Properties.

b.

On the General tab, fill in the Dataset name field with DataSet_Result and click OK to close the Tablix Properties window.

c.

In the inserted list, right-click on the shaded border of the selected row again and then click Row Group, Group Properties.

d.

On the General tab, under Group expressions, click Add, click the drop-down arrow next to the Group on, and select the [Cust_No_] value to set up grouping of data by customer number.

e.

On the Page Breaks tab, select the Between each instance of a group page break option and click OK to close the window.

f.

Insert a table to store the customer data (customer number, name, address, phone number, and email).

g.

Since this table must display one customer at a time, all customer fields must be put into table header rows; the table data and footer rows must be disabled.

h.

In the Toolbox pane, click the Table control and drag the table to place it inside the list.

i.

Shrink the table to about half the list width.

FIGURE 2.27: TABLE DATA REGION WINDOW j.

Select any table row, right-click the shaded border and then click Tablix Properties. On the General tab, ensure that the Dataset name field is populated with DataSet_Result and then click OK.

k.

Right-click any column header and then click Insert Column, and select either Left or Right option to have four columns in the table.

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

2 - 35

Reporting in Microsoft Dynamics® NAV 2013 l.

Select the second table row, which is the Data row. Right-click on the selected row and then click Delete Rows to delete the table details row.

m. Click OK on the confirmation message to delete the row and its associated groups. Disable the table footer in a similar way (if present). n.

Select the only table row left, right-click on the shaded border to the left side of it and then click Insert Row, Below to insert another table header row.

o.

Repeat this action to have three table header rows in the table.

p.

Right-click the first cell in the table, and then click Expression. In the Set Expression area, enter the following expression in the text box: =Parameters!Cust_No_Caption.Value and click OK to close the window.

q.

Do the same for the cell below this one, and assign the =Parameters!NameCaption.Value value to the cell.

r.

Ensure that the values of all caption fields begin with =Parameters. You can select caption values from the Parameters category.

FIGURE 2.28: PARMETERS NAME CAPTION VALUE WINDOW s.

2 - 36

Place the values of the No. and Name fields of the Customer table in the second table column, next to their respective captions, by selecting the fields from the Fields (DataSet_Result) category. Ensure that the values of all fields begin with =Fields. The expressions should be =Fields!Cust_No_.Value and =Fields!Name.Value for the No. and Name fields respectively.

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

Module 2: Interactive Features

FIGURE 2.29: CUSTOMER NO WINDOW t.

Place the values which represent the captions of the Address, Phone No., and E-Mail fields of the Customer table into the third table column.

u.

Place the values of the Address, Phone No., and E-Mail fields of the Customer table into the fourth table column, next to their respective captions.

v.

Ensure the values of fields do not contain any additional operators, such as Sum to avoid unnecessary calculations.

w. The Sum function may be inserted into a field value automatically by the program if the data set name for a list control is empty. x.

Select all table rows (not the table itself). Click View, Properties to open the Properties window if not already shown in the right bottom corner of the Visual Studio Report designer.

y.

Locate the BackgroundColor property and set it to an arbitrary color.

FIGURE 2.30: BACKGROUNDCOLOR WINDOW z.

In the menu bar, click Build, Build Web Site.

aa. Inspect the Output pane and ensure that there are no errors.

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

2 - 37

Reporting in Microsoft Dynamics® NAV 2013 It is a good practice to use the Build Web Site function periodically during the report design to ensure there are no errors or receive detailed information about report design issues if any. 8.

Insert a new table. a.

Insert another table to store the customer ledger entries and detailed ledger entries. Place the table below the one created previously.

b.

Select the table, right-click the shaded border and then click Tablix Properties.

c.

On the General tab, ensure that the Data set name field is populated with DataSet_Result and then click OK.

d.

Select and right-click the table Data row, and then select Insert Row, Outside Group – Below.

e.

Insert a parent group to store the customer ledger entry field captions and values.

f.

Select and delete the first row of the table.

g.

Add columns to the table so that the total number of columns is eleven.

h.

Click the table Data row, right-click the shaded border to the left and then click Add Group, Parent Group.

i.

In the Tablix group window, under Group by, set up grouping by the following expression: [CLE_Entry_No_], select Add group header and click OK.

FIGURE 2.31: INSERT GROUP WINDOW

2 - 38

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

Module 2: Interactive Features j.

Populate the group header row with the customer ledger entry data captions.

k.

Select the first row where the cell expression is [CLE_Entry_No_], right-click on it, and then click Insert Row, Inside Group – Above.

FIGURE 2.32: INSERT ROW WINDOW l.

Populate the inserted row with the caption values of the fields from the Customer Ledger Entry table. Assign the text box expressions for the Customer table as described above. You need to insert caption values for the following fields from the Customer Ledger Entry table: i.

CLE_Entry No.

ii.

Customer No.

iii. CLE_Posting Date iv. CLE_Document Type v.

CLE_Document No.

vi. Description vii. Currency Code viii. CLE_Amount ix. Original Amt. (LCY) x.

Remaining Amt. (LCY)

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

2 - 39

Reporting in Microsoft Dynamics® NAV 2013 m. Skip the column between Description and Currency Code fields.

FIGURE 2.33: ADD FIELDS WINDOW

2 - 40

n.

For the left-most grouping cell in the table, right-click and select Text Box Properties. Select the Visibility tab, and set Hide in the Change display options area. Click OK to close the Text Box Properties window. This will create the necessary indent under the Customer table.

o.

When needed, shrink the columns to make the table fit inside the list.

p.

Populate the second group row with values of the fields of the Customer Ledger Entry table.

q.

Select the first group header row and set the BackgroundColor property in the Properties window for it to an arbitrary color.

r.

Repeat the same action for the second group header row, but make it a different color.

s.

Insert another row below in the group to store detailed ledger entry captions.

t.

Select the second table row, right-click the shaded border to the left of it and then click Insert Row, Below. As a result, you should have a table with 3 group rows, and 1 group data row, and 1 table footer row.

u.

Place the appropriate detailed ledger entry field captions into the third row.

v.

You need to insert caption values for the following fields from the Detailed Cust. Ledg. Entry table: 

DCLE_Entry No.



Entry Type



DCLE_Posting Date



DCLE_Document Type



DCLE_Document No.



Transaction No.



Journal Batch Name

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

Module 2: Interactive Features

9.



Amount (LCY)



Debit Amount (LCY)



Credit Amount (LCY)

To ensure that the Entry No. and Entry Type fields are located directly under the Customer No. field of the customer ledger entry, follow these steps: a.

Shrink the column containing the Customer No. field of the customer ledger entry to about half of its size.

b.

Right-click the column header and then click Insert Column, Right.

c.

Merge the cell containing the caption of the Customer No. field with the cell in the inserted column by selecting the two cells, right-clicking them, and then clicking Merge Cells. Do the same for the cell containing the value of the Customer No. field (next row below).

d.

Repeat the same for the value of the Description fields (caption and value rows).

e.

Assign expressions representing the captions of the Entry No. and Entry type fields of the Detailed Customer Ledger Entry table to the text boxes in the first data row.

f.

A similar procedure must be performed for the Transaction No. and Journal Batch Name fields, which must be located under the Description field of the Customer Ledger Entry table. Insert the rest of the fields from the table (see the list above).

g.

Leave blank cells where empty space must be located (under the Currency Code field of the Customer Ledger Entry table and to the left of that column). Select the group row and set the BackgroundColor property for it to an arbitrary color.

FIGURE 2.34: MERGED CELLS WINDOW h.

Ensure that the values of all caption fields begin with =Parameters (displayed as @) and the values of fields do not contain any additional operators.

i.

Fill the last table row, which is the Data row, with values of the appropriate detailed customer ledger entry fields by placing them below the corresponding captions (see the list above).

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

2 - 41

Reporting in Microsoft Dynamics® NAV 2013 j.

Set the BackgroundColor property for the details row to an arbitrary color.

FIGURE 2.35: DETAILS BACKGROUNDCOLOR WINDOW 10. To hide the empty cells with no data, we need to place the relevant filters. a.

Select any row which is grouped by [CLE_Entry_No_], right-click on the shaded border to the left of it, and click Row Group, Group Properties.

b.

In the Group Properties window, select the Filters tab and click Add to add a filter as shown in the screenshot and click OK to apply the filter.

FIGURE 2.36: GROUP PROPERTIES WINDOW

2 - 42

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

Module 2: Interactive Features 11. Place the field that displays the total amount with its respective caption into the footer row of the table storing the ledger entry data. a.

For the last row of the table, under the Amount field from the Cust. Ledger Entry table, assign the following expression to the text box: =Sum(Fields!CLE_Amount.Value).

b.

For the filled in cell, in the Properties window, click the AssistButton next to the Format property and select Expression. In the Expression window, enter the formatting expression for this text box as follows: =Fields!CLE_AmountFormat.Value.

c.

Click OK.

d.

Merge the two cells located to the left of the inserted field.

e.

Locate the data set item which represents the caption for the total field (Total_Caption) and assign its expression to the merged cell.

f.

In case the cell in the top row of the current column is populated with Total Caption, clear it.

g.

Select these two cells and set the BackgroundColor property for them to a different arbitrary color.

12. Hide the total amount for the cases where no customer ledger entry is available. a.

For the last table row, in the Properties window, click the AssistButton next to the Hidden property and select Expression. In the Expression window, enter the hidden expression for this row as follows: =Fields!CLE_Entry_No_.Value = 0.

b.

Click OK.

c.

Right-click the left-most cell in the last table row and select Text Box Properties.

d.

Select the Visibility tab, and set Hide in the Change display options area.

e.

Click OK to close the Text Box Properties window.

13. Insert another table to store the sales document data. a.

In the Toolbox pane, click the Table control and drag it to the list below the Cust. Ledger Entry table.

b.

Shrink the table to about half the list width.

c.

Insert columns into the table to have a total of five columns.

d.

Delete the first header row from the table.

e.

Select the data row and right-click on the left shaded border to the left. Click Add Group, Parent Group.

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

2 - 43

Reporting in Microsoft Dynamics® NAV 2013 f.

Click the Expression button next to the Group by field, doubleclick Sales_Documents_Caption from the Parameters category and click OK.

g.

Select the Add group header check box.

FIGURE 2.37: TABLIX GROUP WINDOW h.

Click OK to add the group.

i.

Right-click the first row in the table, and then click Insert Row, Inside Group – Above.

j.

Reduce the size of the first column, which is the grouping one. Set its Hidden property to True.

k.

For the first table row, merge all cells (except the first large grouping cell) and, in the Parameters category, locate the data set item which represents the caption of the sales documents section (Sales_Documents_Caption). Make sure that expression is as follows: =Parameters!Sales_Documents_Caption.Value

l.

Fill in the second table group header row with the appropriate captions of the Sales Header table.

m. Captions for the following fields from the Sales Header table are required:

2 - 44



SH_Document Type



SH_No.



SH_Posting Date



Prices Including VAT



SH_Amount

n.

The values of all caption fields should begin with =Parameters.

o.

Select the two table header rows and set the BackgroundColor property for them to an arbitrary color.

p.

Fill in the table data row with the data set items for the field values of the Sales Header table which correspond to the captions inserted into the header.

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

Module 2: Interactive Features q.

Select the table data row and set the BackgroundColor property to a different arbitrary color.

r.

Select any row from this table, right-click the shaded border to the left of it and then click Tablix Properties.

s.

Go to the Filters tab and set a filter as shown in the screenshot, and then click OK.

t.

Resize the list control so that it exactly matches the height of the three tables inside it. Resize the report body section so that it exactly is the size of the list control.

u.

In the menu bar, click Build, Build Web Site.

v.

Inspect the Output pane and ensure that there are no errors.

w. Click the Close button to exit Microsoft Visual Studio. x.

Click Yes to save the modified files.

y.

Go back to the Dynamics NAV 7 Development Environment, and in the Report Dataset Designer, select either a blank line or another data item (a data item that differs from the current selected data item).

z.

Click Yes on the warning message stating that the report layout has been changed by another application, and asking to load the changes.

aa. Save and compile the report in the Object Designer. bb. Run the report from the Object Designer. cc. Ensure that no filters are specified on the request page and click Preview. dd. Click the Print Layout button in the Print Preview window. ee. Observe the report output (the 1st and 2nd pages of the report are displayed in the screenshot below).

Using Images in a Report Using Images in a Report An image is a report item that contains a reference to an image that is stored externally, embedded within the report, or stored in a database. An image can be a logo or picture, or it can be a picture that is repeated with rows of data. You can also use an image as a background for certain report items. When you use an external image in a report, the image item contains a path that points to an image on the server or network. When you use an embedded image, however, the image data is stored within the report definition and does not exist as a separate file.

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

2 - 45

Reporting in Microsoft Dynamics® NAV 2013 External images work well for logos and static pictures that are shared among several reports. Embedded images ensure that the images are always available to the report, but they cannot be shared. Report definitions with external images are smaller than definitions with embedded images. Data-bound images can also be displayed from binary data stored in a database. For example, the pictures that appear alongside product names in a product list are database images. Images can be displayed using the Image control. In the Visual Studio Report Designer, you can work with three sources of pictures: •

Embedded images



External images



Database images (Stored in BLOB fields and streamed with the dataset.)

Embedded Images Embedded images are images that are stored in the report. To import images in the report, select Report Data, New Image. Click the New Image button, select an image file, and click OK. You can embed images in a report so that all image data is stored within the report definition. When you embed an image, Report Designer encodes the image and then stores it as text in the report definition. Using an embedded image ensures that the image is always available to the report, but it also increases the size of the report definition. External Images External images are not stored in the report or in a database. Instead they come from a public external location, for example, the Internet. External pictures are supported in Microsoft Dynamics NAV 2013. To use external pictures, the EnableExternalImages property must be set to True. Using external pictures is not recommended for security reasons. You can include stored images in a report by specifying a Uniform Resource Locator (URL) to the image. When you use an external image in a report, the image source is set to External and the value for the image is the URL address to the image.

2 - 46

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

Module 2: Interactive Features Database Pictures from Microsoft Dynamics NAV In the report, you can also work with pictures that are derived from the Microsoft Dynamics NAV database, for example, to print an item catalog that includes the item pictures, or to print the company logo that is stored in the Company Information table. Database pictures can be added to Header, Body and Footer sections. Image Properties When working with pictures, there are three important properties: •

Source: This property indicates the source of the picture. Supported options in Microsoft Dynamics NAV 2013 are External, Embedded and Database. You can also use an expression to define the picture source.



MIME Type: This property contains the MIME Type of the picture; MIME is an Internet standard for describing the contents of a file. The property is used in HTML to render the picture in the correct way. Examples are image/bmp, image/gif, image/jpeg and so on. MIMEType applies only if the Source property is set to Database. If the Source property is set to External or Embedded, the value of MIMEType is ignored.



Value: This property contains the name of the picture that is displayed in the image control. The property can contain an image name (for embedded images) or a field from the dataset (for database images).

Adding Images To add an image to a report, you must first add a control to the report that can contain an image: the image control. A prerequisite of adding a database image course is that the image is part of the dataset, which implies that the image must be added as a Column in the Report Dataset Designer. If you want to print a "standalone" picture (such as a company logo), you can work with a single Image control. If you want to print a picture as part of a record, you will have to work with a repeating container (such as a table control), and insert an image control in a table cell. After you insert the Image control, you can use the other properties to further fine-tune the layout and the position of the image control.

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

2 - 47

Reporting in Microsoft Dynamics® NAV 2013 Background Images You can use an image as a background image in the body, header and/or footer of the report or in a rectangle, text box, list, matrix, or table. A background image has the same properties as an image. You can also specify how the image is repeated to fill the background of the item. If you define a background image for the report body, but not the page header or footer, HTML reports will automatically use the same background image in all three regions of the report. If you do not want to use the background image in the header or footer, you must explicitly define a different image for those regions. If you do not want any image to appear in those regions, you can create and assign a small transparent image to the header or footer to create the effect of having no image at all.

Demonstration: Adding an Image Control Mort is asked to modify the layout of an existing report, and add an image.

Demonstration Steps 1.

2 - 48

To add an image control to the report, follow these steps. a.

In the Object Designer, select report 123456700 and click Design.

b.

Select View, Layout to open Visual Studio Report Designer.

c.

In Visual Studio Report Designer, click Image in the Toolbox.

d.

Click a location on the design surface and drag the mouse to create a box that is the size of the desired image. Alternatively, click the design surface to create an image item of fixed size.

e.

In the General page of the Image Properties dialog box, type a name in the Name text box or accept the default.

f.

(Optional) In the Tooltip text box, type text to display when the user hovers the mouse over the image in a report generated for HTML.

g.

In Select the image source, click the option that specifies where the source for the image exists. i.

External Choose this option when you specify an image that exists on the report server or on a web server. For this option, you must type a URL to the image or select a dataset field that contains a URL to the image.

ii.

Embedded Choose this option when you specify an image that is part of the report definition.

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

Module 2: Interactive Features iii. Database Choose this option when you specify a dataset field that is bound to a database field that contains an image. h.

Click OK.

i.

(Optional) Click Size, Visibility, Action, or Border to set additional properties for the image report item.

Demonstration: Display an Embedded Picture in a Report Demonstration Steps 1.

To add an embedded image in a report: a.

In Visual Studio Report Designer, in the Report Data pane, rightclick the Images node, and then click Add Image.

b.

Alternatively, click Import, navigate to the file, and then click Open. In Files of type, select the image file type, select the file Image.png, click Open and then click OK.

The file is displayed under the Images folder in the Report Data pane. c.

The MIME type is derived when the image is imported. To change the MIME type, view the next procedure.

d.

To add the image to the report, drag the image from the Report Data pane to the design surface. The Image Properties dialog box opens.

e.

Click OK.

Demonstration: Adding a Database Image to a Report Demonstration Steps 1.

To a Database Image to a Report: a.

In Visual Studio Report Designer, click Image in the Toolbox.

b.

On the design surface, click the design surface and then drag the mouse to create a box that is the size of the desired image. Alternatively, click the design surface to create an image item of fixed size.

c.

In the Image Properties dialog box, type a name in the Name text box, or accept the default.

d.

(Optional) In the Tooltip text box, type text that will display when the user hovers the mouse over the image in the rendered report.

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

2 - 49

Reporting in Microsoft Dynamics® NAV 2013 e.

In Select the image source, select Database.

f.

In Use this Field, select the field that contains the image.

g.

In Use this MIME type, select the MIME type of the image.

h.

Click OK.

Demonstration: Adding a Background Image for a Report Background images apply to a rectangle, text box, tablix, page header, page footer, report body, chart, and some parts of a chart, for example, a chart area. You can define a background image for any selected item on the report design surface that displays BackgroundImage in the Properties pane. If the Properties pane is not visible, from the View menu, click Properties Window.

Demonstration Steps

2 - 50

1.

In Visual Studio Report Designer, select the report item to which you want to add a background image.

2.

In the Properties pane, expand BackgroundImage, and then do the following: a.

For Source, select External, Embedded, or Database.

b.

For Value, type or select an expression that evaluates to the source of the image.

c.

If the Source property is set to External, the expression must evaluate to a valid path to an image. This can be a static path to an image hosted on a report server, or it can be a path based on a field.

d.

If the Source property is set to Embedded, the expression must evaluate to the name of an image that is embedded in the report. If the Source property is set to Database, the expression must evaluate to a field that contains binary image data.

e.

For MIMEType, select the appropriate MIME type for the image.

f.

MIMEType applies only if the Source property is set to Database. If the Source property is set to External or Embedded, the value of MIMEType is ignored.

g.

For BackgroundRepeat, select Repeat, NoRepeat, RepeatX, or RepeatY.

h.

For background images in a chart, BackgroundRepeat can be set to Fit, but not RepeatX or RepeatY.

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

Module 2: Interactive Features

Print Preview and Print Layout This section explains the difference between the two modes: Print Preview and Print Layout.

How Does It Work? When you run a report, a request page appears (If you have set this to appear). In this page, you can have three options: •

Cancel the report.



Print (or export) the report.



Preview the report.

Cancel will close the pop-up menu and you will return to the client. Print will send the report to the printer, but Preview will open the Report Viewer. In addition to these options in the request page, you can also apply filters to the report, or fill in options in the Options Tab, if options are defined for the report. You can use the Report Viewer to preview the report before you send it to the printer, or save it as a PDF or Microsoft Excel™ or Microsoft Word™ file. At the top of the Report Viewer window there is a toolbar with several buttons.

FIGURE 2.38: THE REPORT VIEWER TOOLBAR WINDOW You can use the Print button to send the report to the printer. Note: Note that the print button is not available if the C/AL code in the report contains the function: currReport.PREVIEW()

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

2 - 51

Reporting in Microsoft Dynamics® NAV 2013 To the right of the Print button is the Print Layout button. If you click the Print Layout button, the report will be regenerated in the Print Layout mode. This mode will provide you with a visual depiction of how the report will print on paper. However, if you select the Print Preview mode, you will not have a visual depiction of the width of the page and the page breaks. By clicking the Print Layout button again, you can switch back to the Print Preview mode. Additional Reading: For more information about report rendering behavior, please read: http://go.microsoft.com/fwlink/?LinkId=267270

Working with Visibility Options This lesson describes the interactive features (such as visibility options, interactive sorting and document maps) that can be added to reports.

Lesson Objectives Describe the visibility options in reports and how to use them.

Visibility Options With the report viewer, the user can dynamically expand and collapse groups of data, and gradually move into the content of a report, which will make the report complete and easier to analyze. Review report 123456700, Sales by Salesperson - L1.1. The report contains an overview of the total sales and profit amount separated by salesperson, country/region code, customer number and document type. Suppose you want to view the sales amount realized by John Roberts, particularly in Germany. You also want to view the details for Germany, and at the same time, you want to view the correct totals for all countries and regions. Once the information is printed, you cannot collapse specific sections. All the details are visible, including those you are not interested in at this time. The next paragraph will show you how to work with visibility options.

The Visibility Feature The Visibility feature is a toggle feature you can use to dynamically show or hide data regions using the Expand/Collapse technique. When you add the visibility feature to a specific data region, the data region will get a small plus (+) icon. If you click it, the region will expand, and at the same time, the icon will change from a plus (+) icon to a minus (-) icon. If you click it again, the region will collapse and the icon will revert to a plus (+) icon.

2 - 52

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

Module 2: Interactive Features Conversely, visibility options defined for a group header will also apply to the corresponding group footer. By providing a toggle on a text box, users can hide and display items interactively. For a table or matrix, you can show or hide static rows and columns, or rows and columns that are associated with groups. The main reason for hiding items is to provide a report that shows summary data, so that a user can drill down into detail data. For example, you can initially hide all the rows except the outer group summary row for a table with row groups. For each inner group (including the details group), add a toggle to the grouping cell of the containing group. When the report is rendered, the user can click the text box to expand and collapse the detail data. Implement the Toggle Visibility Functionality The visibility feature is typically used in data region controls, to influence the visibility of grouped data (table rows, matrix columns). Although it can be defined for each cell, you normally define it by table row. Often you will define visibility options for all levels except the highest data level. Visibility options are often defined in a cascading scenario. Visibility and Totaling Although you have added visibility options for the different groupings, you still need to expand the different groups and examine the group footers to know the subtotals for each group. To avoid this, you can have the totals display in the group header row, so that the subtotals are visible without having to expand the individual groups. (In this case, the group footers become obsolete.) To add the totals to the group header, select the fields in the dataset and drag them to the correct cell in the group header. (You can also copy or move the fields from the footer row.) When you add a numerical field to a header or footer, the Sum() function will be added automatically. As a result, the header will contain the same information as the footer. You can now disable the individual footers, as described in the Delete a Group Header or Group Footer section.

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

2 - 53

Reporting in Microsoft Dynamics® NAV 2013 Demonstration: Adding Toggle Visibility Options In report 123456700, you would define visibility options for the Country/Region Code, Customer No. and Document Type group headers and the table details row (showing the individual customer ledger entries).

Demonstration Steps 1.

The following steps show how to define visibility options for a table row. a.

Import Report R123456721.fob and confirm.

b.

Click Design to open the Report Dataset Designer.

c.

Select View, Layout to open Visual Studio Report Designer.

d.

Click the row group in the Row Groups window for the group you want to add visibility options to. In this case, select the Country/Region Code group (group2).

e.

Select Group Properties.

f.

On the Visibility Tab, select an initial visibility state for the data level. The default state is Show (which means that the data region will be expanded). If you select Hide, the data region will be collapsed. Select Hide.

g.

Select the Display can be toggled by this report item check mark.

h.

In the Report Item field, select the control that can influence the visibility of the selected table row. Select Customer__Salesperson_Code_.value.

i.

Click OK to close the Grouping Properties window.

Now that you have defined the visibility for one level, you can repeat this procedure to define it for the remaining levels. If you run the report afterward, the result will be similar to the Report With Visibility Options figure.

FIGURE 2.39: REPORT WITH VISIBILITY OPTIONS WINDOW

2 - 54

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

Module 2: Interactive Features Notice that the report shows only the two salespersons. The details for the Country/Region Code grouping (and all underlying groupings) are hidden. If you click the Expand/Collapse icon, the details of the next level are shown; if you click the button again, the details are hidden again. You can have the initial visibility state determined by an expression. This is often used to influence the visibility of individual controls. Using expressions will be described in the Adding Code to a Report module.

Interactive Sorting Sorting data in the Microsoft Dynamics NAV pages is strictly related to keys. These can be single or multiple field keys defined and enabled at table structure level. The different sorting orders for data must be defined as keys. After you define a key, you can use it in tables, pages, reports, and other objects to sort data in the order that you want, according to one of these keys. And you can also use these programmatically. In reports, you can have the user define the sorting order, or you can predefine the sorting order (using the DataItemTableView property on data item level). In either way, the sorting order is defined before the report is printed. If a different sorting order is required, you must run the report again. The report viewer client also supports interactive sorting. This means that you can add sort buttons to the data columns and use them to change the sorting of the data after the report is run, in preview mode. When you view the report, columns that support interactive sorting have arrow icons that change to indicate the sort order. The first time you click an interactive sort button, items are sorted in ascending order. Subsequent clicks toggle the sort order between ascending and descending order. When you work with interactive sorting, you will be able to support multiple user requirements while minimizing development time. Note: Note that implementing interactive sorting on a report that has a big dataset, might have a negative impact on performance.

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

2 - 55

Reporting in Microsoft Dynamics® NAV 2013 What is Interactive Sorting Interactive sorting can be defined on multiple columns. In reports without grouping, the data will be sorted according to the selected column and the selected sort order (ascending or descending). In this case, interactive sorting will affect the whole data region, from top to bottom and from left to right, and equals interactive grouping: data will be sorted and also grouped differently (because each record will be a group on its own). In reports with grouping, interactive sorting will depend on grouping. The interactive sort functionality is limited to a specific group of data. By changing the sorting of a specific group, you will affect the sorting of the data in the current group (and underlying groups), but it should not affect the sorting and will not affect the grouping that is defined on a higher level. For reports with grouping, it is important to define the correct sorting scope. For each column the user can select the sort order. For example, you can have the first column sorted in ascending order, the second in descending order, and the third in ascending order again. Visibility options might have a side-effect on interactive sorting: when you change the sorting on a column, the data for the current group will be refreshed, taking into account the Initial visibility settings. When you combine interactive sorting and visibility options, you must remember to first select the right sorting order for the different columns before you expand the data groups. The most common use of an interactive sort is to add a sort button to all column headers. The user can then choose which column to sort by. When you add an interactive sort, you must specify the following items:

2 - 56



What to sort: Rows or columns?



What to sort by: A field that is displayed in a table column? A field that is not displayed?



What context to sort in: For example, you can sort on rows associated with row groups, columns associated with column groups, detail rows, child groups within a parent group, or parent and child group together.



Which text box to add the sort button to: In the column header or in the group row header?



Whether to synchronize the sort for multiple data regions: You can design a report so that when the user toggles the sort order, other data regions with the same ancestor also sort.

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

Module 2: Interactive Features Demonstration: Adding Interactive Sorting - No Grouping Mort needs to add interactive sorting to report 101, Customer - List, so that customers can be sorted interactively on the salesperson code. The following steps show how to activate interactive sorting for a column in a report without grouping.

Demonstration Steps 1.

Open report 123456700 in Visual Studio Report Designer. a.

Right-click the cell (first row, second column) and select Text Box Properties to open the Text Box Properties window.

b.

On the Interactive Sorting Tab, enter a check mark in Enable an interactive sort action on this text box.

c.

In the Sort by field, select the name of the field to sort on, for example [Customer__Salesperson_Code_].

FIGURE 2.40: ADDING AN INTERACTIVE SORT TO A TEXT BOX WINDOW d.

Click OK to close the Text Box Properties window.

e.

Exit Visual Studio, save and import the RDLC changes, save and compile the report in the Report Designer and run the report.

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

2 - 57

Reporting in Microsoft Dynamics® NAV 2013 Demonstration: Adding Interactive Sorting - Grouping (Group Header Field) After he introduced interactive sorting in some reports, Mort receives similar requests for other reports. Michael asks him to change the sorting in report 123456713, Customer/Item Sales 2, so that he can sort by Customer No. Additionally, Michael wants to sort the data by Item No. and by Item Description. Mort will first define interactive sorting on the Customer No. field, which is a group header field.

Demonstration Steps 1.

2 - 58

The following steps show how to activate interactive sorting for a group header field in a report with grouping. a.

Select Tools, Object Designer to open the Object Designer.

b.

Select File, Import.

c.

Browse to the report R123456713.fob.

d.

Click Open to start the import.

e.

In the dialog box, choose to open the Import Worksheet window.

f.

In the Action column, verify that the action is set to Create.

g.

Click Open to import the object in the database

h.

Open report 123456713 in Visual Studio Report Designer.

i.

Select the header cell for the column you want to add an interactive sort to. In this case, an interactive sort must be added to the Customer No. column. Note that the Customer No. column does not contain a caption. You can either include one or leave it blank.

j.

Right-click the cell and select Text Box Properties to open the Text Box Properties window.

k.

On the Interactive Sorting Tab, enter a check mark in Enable interactive sorting on this text box.

l.

In the Sort by field, select the name of the field to sort on, and then select [Customer__No__].

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

Module 2: Interactive Features m. In Choose what to Sort: select the Group option. n.

In the Choose data region or grouping field, select Table1_Group. This means that changing the sort order will only affect the selected group (and the underlying groups). It is important that you select the correct scope for each group).

FIGURE 2.41: INTERACTIVE SORT FOR A GROUP HEADER FIELD WINDOW o.

Click OK to close the Text Box Properties window.

Exit Visual Studio, save and import the RDLC changes, save and compile the report in Report Designer and run the report.

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

2 - 59

Reporting in Microsoft Dynamics® NAV 2013 Demonstration: Adding Interactive Sorting - Grouping (Detail Field) Now that an interactive sort is added to the Customer No. field, Mort needs to add interactive sorting for the Item No. and Item Description fields.

Demonstration Steps 1.

2 - 60

The following step shows how to activate interactive sorting for a detail column in a report with grouping: a.

Open the report in Visual Studio Report Designer.

b.

Select the header cell for the column you want to add an interactive sort to. In this case, you will add an interactive sort to the Item No. field (in the first column).

c.

Right-click the cell and select Text Box Properties to open the Text Box Properties window.

d.

On the Interactive Sorting Tab, enter a check mark in Enable interactive sorting on this text box.

e.

In the Sort by field, select the name of the field to sort on. In this case, select [ValueEntryBuffer__Item_No__]

f.

In the Choose what to sort, select the Detail Rows. This means that changing the sort order will only affect the detail scope of the table.

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

Module 2: Interactive Features

FIGURE 2.42: INTERACTIVE SORT FOR A DETAIL ROW FIELD WINDOW g.

Click OK to close the Text Box Properties window.

h.

Next, you will add an interactive sort to the Item Description field (in the first row, third column).

i.

Right-click the cell and select Text Box Properties to open the Text Box Properties window.

j.

On the Interactive Sort Tab, enter a check mark in Enable an interactive sort action on this text box.

k.

In the Sort by field, select the name of the field to sort on. In this case, select [Item_Description].

l.

In the Choose data region or grouping field, again select the Detail Rows option.

m. Click OK to close the Text Box Properties window. n.

Exit Visual Studio, save and import the RDLC changes, save and compile the report in the Report Designer and run the report.

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

2 - 61

Reporting in Microsoft Dynamics® NAV 2013

Working with Document Maps In this lesson, you will learn how to improve the navigation of a report by working with a document map, and how to define a name and map levels for the document map. Additionally, you will learn what happens to the document map when you export it in different formats.

Lesson Objectives Explain how document maps work and how to add them to a report.

What is a Document Map A document map is a report feature that is used to quickly navigate through the contents of a report. The document map has a tree view structure. It appears as a separate side pane next to the report content, and functions as a table of contents. When you click an item in the document map, the report content at the right side will be refreshed. If you change the sorting of the report, the document map will be rebuilt to follow the sorting of the document. The document map will be rendered differently depending on how the report will be exported: •

PDF renders a document map as the Bookmarks pane. All items in the document map are listed one after the other down the pane. There is no hierarchy to the list of links.



Microsoft Excel renders a document map as a named worksheet that includes a hierarchy of links. Report sections are rendered in separate worksheets that are included with the document map in the same workbook.



Microsoft Word does not render the document map.

You can use a document map in a report so that users can navigate to certain areas of the report. When you view an Excel or PDF report, a document map appears on the side of the report. Clicking items in the document map refreshes the report and displays the area of the report that corresponds to the item in the document map. You can add multiple document maps to a report. If the report contains multiple data region controls, you can add a document map for each data region control. In this case, it is recommended to specify a document map label for each data region control. Document maps provide a hierarchical overview of the information in the report, and they can contain entries for the different groups that are defined.

2 - 62

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

Module 2: Interactive Features Demonstration: Adding a Document Map Demonstration Steps 1.

The following steps show how to create a document map. a.

Open report 123456700 in Visual Studio Report Designer.

b.

On the Row Groups Tab, select the group that you want to include in the document map, for example Group1, and click Group Properties.

c.

In the Advanced Tab, in the Document map field, select the field that you want to show in the document map. In this example, select [Customer__Salesperson_Code_]. (You can select other fields than the one in the Group on field. For example, you can group the data on Customer No. and include the Customer Name in the document map. You can even combine multiple fields by entering an expression.)

d.

Click OK to close the Grouping Properties window.

e.

Repeat steps 2 through 4 for each group level that you want to include in the document map (Group2, Group3, Group4) and the corresponding fields([Customer__Country_Region_Code_], [Customer__No__], [Cust__Ledger_Entry__Document_Type_]).

f.

On the tablix properties, enter a name for the data region in the DocumentMapLabel field. You can use the name to identify the data region control in the document map. This is convenient if the report contains multiple data region controls.

g.

Exit Visual Studio, save and import the RDLC changes, and then save and compile the report in the Report Designer.

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

2 - 63

Reporting in Microsoft Dynamics® NAV 2013 When you run the report, the result is similar to the A Report With A Document Map figure.

FIGURE 2.43: A REPORT WITH A DOCUMENT MAP WINDOW Notice the Expand button in the top left corner. Note: If you want to hide the Document Map you could do this in two ways. Click in the small left arrow placed in the middle of the separating column between document map and report or right click anywhere in the report and uncheck the Document Map option.

The Document Map Settings The document map settings are defined in the Grouping Properties window. If this is how you define the document map settings, you must open the Table Properties window instead to specify a document map label for the table. Specifying a document map label for the table is not mandatory. However it is recommended to do this when the report contains multiple data region controls. If you do not specify any names for the different tables, all document map entries will be included sequentially, and the document map will lose some of its added value.

2 - 64

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

Module 2: Interactive Features You can also include a document map in reports that do not define groups. 1.

In the Row Groups window, select the detail group and select Group Properties.

2.

On the Advances Tab, select the field that you want to add to the map in the DocumentMapLabel field.

3.

In the Group by field, select the field that you want to group the data on. This is typically the default sorting field.

4.

Click OK to close the Group Properties window.

Creating a Multi Column Report What is a Newsletter Style Report You can design multi-column newsletter-style reports whereby data flows down multiple adjacent columns. A newsletter-style layout applies to the entire report. It is not possible to specify a newsletter-style layout on the top half of the report, and a tabular layout on the bottom half of the report. When you specify a newsletter-style layout, the report server creates each column as a series of very narrow pages that are rendered in close sequence, giving the appearance of multiple columns. Properties that you set at the page level are applied to each column in the report. You can define as many columns you want. For best results, use the Table or List data region.

Viewing a Multi Column Report Not all rendering extensions support a newsletter-style layout. You can use the following rendering extension to view a newsletter-style report: •

PDF

You can preview a newsletter-style report using Print Preview. In Preview and in the rendering extensions that produce Excel and Word output, a newsletter-style layout is displayed as a single column. To view a newsletter-style report, you must export it to a PDF file, and then open the file from the file system. For best results, consider to create a codeunit that delivers the report as a .pdf file to a shared folder location.

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

2 - 65

Reporting in Microsoft Dynamics® NAV 2013 Demonstration: Create a Newsletter-Style Report Multicolumn, newsletter-style reports display report data down multiple adjacent columns. A newsletter-style layout applies to the entire report. When you define more than one column in a report, Report Viewer calculates the width of the columns in the report, the width of the report, and the width of the space between columns based on the number of columns. It then displays a reduced design surface so that you can place report items on the report that will fit within the column. Note that the layout of the entire report must be placed on the reduced design surface. Additional columns are displayed so that you can verify that the number of columns you defined will fit the page size dimension. You can adjust page size, padding, and margins to fit more columns on the page.

Demonstration Steps 1.

2 - 66

To create a newsletter-style report a.

Select Tools, Object Designer to open the Object Designer.

b.

Select File, Import.

c.

Browse to the report R123456716.fob.

d.

Click Open to start the import.

e.

In the dialog box, choose to open the Import Worksheet window.

f.

In the Action column, verify that the action is set to Create.

g.

Click Open to import the object in the database.

h.

Open report 123456716 in Visual Studio Report Designer.

i.

In Visual Studio Report Designer, select Report from the dropdown list in the Properties pane. The report properties appear in the Properties pane.

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

Module 2: Interactive Features j.

In the Properties pane, expand the Columns node.

k.

In Columns, type 2 as the number of columns in the report.

l.

In ColumnSpacing, type the width of the space between columns as 0.5in.

FIGURE 2.44: MULTI COLUMN REPORT WINDOW Note: The default unit of measurement is based on the user's locale settings. To designate a different unit, type a physical unit designator such as cm, mm, pt, or pc after the numeric value.

Formatting Reports and Report Items Formatting the items in your report makes the report look more attractive and enhances its readability. You can format the text boxes and individual items within text boxes, the images, the expressions, and the data while in design mode. You can change formatting options by selecting the item that you want to format and then opening the item's Properties dialog box. For example, if you want to format the contents of an entire text box or a selected word within the text box, right-click the item and select Text Box Properties. Then, you can apply the formatting styles that you want.

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

2 - 67

Reporting in Microsoft Dynamics® NAV 2013 To Format a Textbox With a Placeholder A text box can be a report item or an individual cell within a data region that contains text, a calculated field, a pointer to a field in a database, or a combination of all three items. You can mix fonts and colors, add bold and italic styles, and use paragraph styles such as alignment and hanging indents. You can format an entire text box or you can format specific text, numbers, expressions, or fields within the text box. Font, size, color, and effects all contribute to the readability of a report. Font, font style, font size, and underline effects can be applied to text within a text box or data region. By default, the report font that is used is Arial, 10 points, and black. By using the Text Box Properties dialog box, you can specify how the text appears when the report is rendered. When a simple or complex expression is defined inside a text box, the resulting UI representation of this expression is known as a placeholder. You can define colors, fonts, actions, and other behavior on any number of placeholders or sections of text within a single text box. The value of a placeholder is always a simple or complex expression. You can add a placeholder to a text box by creating an expression using one of the following methods:

2 - 68



Drag a field from the Report Data pane and drop it into the text box. If you drag the expression anywhere else on the report body, a new text box will be created that contains the placeholder. The value of this placeholder will be the field expression that corresponds to the field that was dropped.



Right-click anywhere in the text box and select Create Placeholder. In the Placeholder Properties dialog box, you can specify an expression as the value of your placeholder.



Type any simple or complex expression into the text box. For example, if you type Name: [Name] into the text box, the [Name] text will be displayed as a placeholder that represents the expression =Fields!Name.Value



Type an expression in an empty text box by starting with an equal sign (=). When you change the focus off the text box, the resulting expression is converted into a placeholder that you can edit. If the text box is not empty, or the equal sign is inserted anywhere but as the first character in the text box, the equal sign is treated as a string literal and a placeholder is not created.

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

Module 2: Interactive Features Formatting Placeholders and Static Text in a Text Box You can format placeholders using the Placeholder Properties dialog box. You can format only the entire placeholder, not sections of the placeholder. If you want to see the underlying expression, you can pause your pointer on the placeholder. You can change the underlying expression by double-clicking the placeholder or right-clicking the placeholder and selecting Placeholder Properties. You can also specify a UI label using the Label property in General of the Placeholder Properties dialog box. This will be the text that is shown at design-time for the placeholder. Unlike placeholder text, you can align individual text in a text box separately, use multiple paragraphs within a single text box, and define other behavior for any subset of text. You can define colors, fonts, actions, and other behavior on any subset of text within a single text box to create a mail merge or template for text in your report. You can also use multiple paragraphs inside a single text box. For example, if you have two separate paragraphs of text, you can separate the paragraphs by pressing ENTER in the text box. You can also set an alignment value for any individual string of text. You can also define an action for individual text in a text box. This can be useful if you want to add a hyperlink for a string of text that is contained inside a text box. Note: Actions defined on the text box have a higher priority than actions defined for individual text in a text box.

Using HTML in a Text Box The text box report item enables you to insert HTML-formatted text that you have retrieved from a field in your dataset into a report. The text can come from any simple or complex expression that evaluates to correctly formatted HTML. Formatted text can be rendered to all supported output formats, including PDF. The following is a list of tags that will render as HTML when defined as placeholder text: •

Hyperlinks:



Fonts:



Header, style and block elements: , , ,, , ,



Text format: , , ,



List handling: , ,

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

2 - 69

Reporting in Microsoft Dynamics® NAV 2013 Any other HTML markup tags will be ignored during report processing. If the HTML represented by the expression in the placeholder text is not well formed, the placeholder is rendered as plain text. All HTML tags are case-insensitive. If the text in your text box contains only one block of text, any HTML in the placeholder that defines block elements will render correctly. However, if the text box has multiple blocks of text, the HTML tags are ignored and the structure of the text is defined by the blocks of text. If more than one tag is defined for text, and Reporting Services detects a conflict between the HTML and existing report constraints, only the innermost HTML tag will be treated as HTML. Note: When you use text that contains HTML markup, the data must always be parsed by the text box first. Because only a subset of HTML tags is supported, the HTML that is shown in the rendered report may differ from your original HTML.

Demonstration: Combine Multiple Formats in a Text Box You can format any part of the text separately within a text box. This ability to mix formats by adding placeholder text enables you to create mail merges or templates for text in your report. Any expression can be defined and formatted separately using a placeholder.

Demonstration Steps 1.

2 - 70

To combine multiple formats in a text box a.

Open report 123456714 in Visual Studio Report Designer.

b.

In the Toolbox, double-click a Textbox report item, or drag it to the design surface.

c.

Inside the text box, type some text and select the text you want to format.

d.

Right-click the selected text, and click Text Properties.

e.

Set formatting options. For example, select the Font tab and in the Style select Bold.

f.

Click OK.

g.

Repeat steps c through f for the remaining text you want to format.

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

Module 2: Interactive Features These steps are visualized in the following diagram:

FIGURE 2.45: TEXT PROPERTIES WINDOW

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

2 - 71

Reporting in Microsoft Dynamics® NAV 2013 Demonstration: Add HTML From a Field in your Dataset into a Text Box Using a placeholder, you can import HTML from a field in your dataset for use in the report. By default, a placeholder represents plain text, so you will need to change the placeholder mark-up type to HTML.

Demonstration Steps 1.

To add HTML from a field in your dataset into a text box a.

Open report 123456714 in Visual Studio Report Designer.

b.

When you drag a field from your dataset into a text box. A placeholder is created for your field.

c.

For example, in the second textbox of the second row, doubleclick and then the Placeholder Properties open.

d.

Click HTML - Interpret HTML tags as styles. This causes the field to be evaluated as HTML.

e.

Click OK.

These steps are visualized in the following diagram:

FIGURE 2.46: PLACEHOLDER PROPERTIES WINDOW

Formatting Lines, Colors, and Images Visual Studio Report Designer Services gives you the ability to format lines, colors, data regions, images, and other report items.

2 - 72

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

Module 2: Interactive Features Borders, Lines and Gridlines Borders, lines, and gridlines can visually tie items together on the page and help your report readers easily read the contents of the report. Using the predefined border styles, you can quickly add a border around a text box, a group of text boxes, or an image. In addition, you can change the style, width, and color for the borders, lines, and gridlines. Borders are added around the entire item selected or around a border along an edge of the item, for example, a border along the bottom of a text box. To format borders and gridlines in a text box, report layout, or around an image, use the report item's Properties, Border dialog box. For example, if you want to add a border around an image, right-click the image and then select Image Properties, Border. In addition to the standard border frames, additional border frames can be applied to charts. Applying Background Colors A solid color can be added to the background of the entire report, a text box within the report, or to a cell or group of cells within a data region. By default, the background color is white; however, you can select a color from the report item's Properties, Fill dialog box. For example, if you want to change the background color of a text box, right-click the text box and select Text Box Properties. Click Fill and then you can select the color you want. In this dialog box, you can select a background color for the selected item or you can add an image that appears in the background. When you use the chart, you can also specify gradients and pattern styles for background colors. Formatting Images Fields that contain images can be added to a data region. If you use an image field, the images appear in the report with the report is run. You can adjust the height and width of the images by changing the display size in the Image Properties, Size dialog box. Images, such as logos, can also be added to the background of your report. If you use an image in your report layout, you can adjust the height and width of the images using the Image Properties dialog box. You can apply a background image to a rectangle, text box, table, matrix, or to the body and page sections of a report.

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

2 - 73

Reporting in Microsoft Dynamics® NAV 2013 Demonstration: Apply a Border to a Chart To give a chart more visual impact, consider using a border frame around the outside of the chart. You can select a border frame by using the Chart Properties dialog box or by using the Properties pane. The chart border frames cannot be applied to any other data region.

Demonstration Steps 1.

To apply a border to a chart: a.

Select Tools, Object Designer to open the Object Designer.

b.

Select File, Import.

c.

Browse to the report R123456709.fob.

d.

Click Open to start the import.

e.

In the dialog box, choose to open the Import Worksheet window.

f.

In the Action column, verify that the action is set to Create.

g.

Click Open to import the object in the database.

h.

In the Object Designer, open report 123456709, Job Actual to Budget - Chart in design mode.

i.

Select View, Layout to open Microsoft Visual Studio.

j.

Right-click anywhere on the chart and select Chart Properties.

k.

If you do not see the Chart Properties, point to Chart on the shortcut menu and select Chart Properties.

l.

Select Border, and click the type of border to apply to the chart.

m. Select a value or type an expression that represents the style of the border.

2 - 74

n.

Specify the color of the line that will be drawn around the chart as the border.

o.

The Line color list contains common colors. If you want to select from a list of more colors, click More colors in the list or click the expression (fx) button next to the list to bring up the Expression editor.

p.

Specify the width of the border. Valid values are between 0.25pt and 20pt. Consider keeping the size of your border to between 1 and 3pt for the best visual effect.

q.

If your report contains a background color other than white, consider defining a page color that is the same color. The page color is the background color outside of the border line.

r.

If you choose a Frame type, specify a style and color for the frame. The Frame fill color list contains common colors.

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

Module 2: Interactive Features Merge Cells in a Data Region You can merge cells in a data region to combine cells, improve data region appearance, or provide spanning labels for column groups and row groups. Cells can only be merged within each area of a data region: corner, column headers, group definition (or row headers), and body. You cannot merge cells that cross area boundaries. For example, you cannot merge a cell in the data region corner area with a cell in the row group area.

Demonstration: Merge Cells Demonstration Steps 1.

To Merge Cells in a data region: a.

In the Object Designer, open report 123456714 in design mode.

b.

Select View, Layout to open Microsoft Visual Studio.

c.

In the data region on the report design surface, click the first cell to merge.

d.

Holding the left mouse button down, drag vertically or horizontally to select adjacent cells. The selected cells are highlighted.

e.

Right-click the selected cells and select Merge Cells.

f.

The selected cells are combined into a single cell.

g.

Repeat steps c and d to merge other adjacent cells in a data region.

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

2 - 75

Reporting in Microsoft Dynamics® NAV 2013 These steps are visualized in the following diagram:

FIGURE 2.47: MERGE CELLS WINDOW

2 - 76

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

Module 2: Interactive Features

Lab 2.1: Adding Visibility Options Scenario In Lab 1.1 Mort finished the rough design of the Sales by Salesperson report. He added the necessary groups and also included subtotals and grand totals. However, Kevin wants some additional information added to the report. He wants to have the totals displayed on a group level (with drill down possibilities). Additionally, he wants the Customer Name printed next to the Customer No. He also wants Mort to use different colors in the headers and footers, to ease report navigation.

Objectives In this lab you will learn how to add interactive features to a report.

Exercise 1: Adding Visibility Options to the Sales by Salesperson Report Exercise Scenario Mort adds the necessary visibility options and the additional information to the report.

Task 1: Adding Visibility Options High Level Steps 1.

Change the report so that:

2.

Add Visibility Options for the Country/Region Code, Customer No., Document Type Levels.

3.

Add Visibility Options for the Detail Row.

4.

Have the Salesperson Group Totals Displayed in the Header.

5.

Have the Country/Region Code Group Totals Displayed in the Header.

6.

Have the Customer No Group Totals Displayed in the Footer.

7.

Have the _Document_Type Group Totals Displayed in the Header.

8.

Add an Information Label to the Customer No. Footer Row.

9.

Change Background Colors of the Headers and Footers.

10. Add the Customer Name to the Customer Group Header. 11. Run the Report.

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

2 - 77

Reporting in Microsoft Dynamics® NAV 2013 Detailed Steps 1.

2.

2 - 78

Change the report so that: a.

By default, only the salesperson codes are displayed.

b.

By clicking the Salesperson Code, the Country/Region Code group will be expanded.

c.

By clicking the Country/Region Code, the Customer No. group will be expanded.

d.

By clicking the Customer No., the Document Type group will be expanded.

e.

By clicking the Document Type, the Customer Ledger Entry details will be expanded.

f.

Subtotals are displayed in the Header rows.

g.

Extra information labels such as "Total for XX" are displayed next to the totals.

h.

The Headers and Footers have different background colors.

i.

The Customer Name is displayed in the Customer Group Header.

Add Visibility Options for the Country/Region Code, Customer No., Document Type Levels. a.

Open the RDLC layout of report 123456700 in the Visual Studio Report Designer.

b.

Right click on the textbox in which the [Customer__Salesperson_Code_] is shown. This is the textbox located in the first column, second row.

c.

In the dropdown menu, select Textbox Properties. The Textbox Properties window opens.

d.

In the Textbox Properties window change the value of the Name field from Group1 to Customer__Salesperson_Code_

e.

Right click on the textbox in which the [Customer__Country_Region_Code_] is shown. This is the textbox located in the second column, third row.

f.

In the dropdown menu, select Textbox Properties. The Textbox Properties window opens.

g.

In the Textbox Properties window change the value of the Name field from Group2 to Customer__Country_Region_Code_

h.

Right click on the textbox in which the [Customer__No__] is shown. This is the textbox located in the third column, fourth row.

i.

In the dropdown menu, select Textbox Properties. The Textbox Properties window opens.

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

Module 2: Interactive Features j.

In the Textbox Properties window change the value of the Name field from Group3 to Customer__No__

k.

Right click on the textbox in which the [Cust__Ledger_Entry__Document_Type_] is shown. This is the textbox located in the fourth column, fifth row.

l.

In the dropdown menu, select Textbox Properties. The Textbox Properties window opens.

m. In the Textbox Properties window change the value of the Name field from Group4 to Cust__Ledger_Entry__Document_Type_ n.

On the Row Groups Tab, select group2 and click Group Properties.

o.

On the Visibility Tab, in the When the report is initially run field, select Hide.

p.

Enter a check mark in the Display can be toggled by this report item field.

q.

In the drop-down list box, select Customer__Salesperson_Code_.

r.

Click OK to close the Grouping Properties window.

s.

On the Groups Tab, select the group3 group and click Group Properties.

t.

On the Visibility Tab, in the When the report is initially run field, select Hide.

u.

Enter a check mark in the Visibility can be toggled by this report item field.

v.

In the drop-down list box, select Customer__Country_Region_Code_.

w. Click OK to close the Grouping Properties window. x.

On the Groups Tab, select the group4 group and click Group Properties.

y.

On the Visibility Tab, in the When the report is initially run field, select Hide.

z.

Enter a check mark in the Visibility can be toggled by this report item field.

aa. In the drop-down list box, select Customer__No__ bb. Click OK to close the Grouping Properties window. 3.

Add Visibility Options for the Detail Row. a.

On the Groups Tab, select the Details and click Group Properties.

b.

On the Visibility Tab, in the When the report is initially run field, select Hide.

c.

Enter a check mark in the Visibility can be toggled by this report item field.

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

2 - 79

Reporting in Microsoft Dynamics® NAV 2013

4.

5.

2 - 80

d.

In the dropped-down list box, select Cust__Ledger_Entry__Document_Type_.

e.

Click OK to close the Grouping Properties window.

Have the Salesperson Group Totals Displayed in the Header. a.

Right-click the row handle for the Salesperson Code group footer.

b.

Select Delete Rows. (The footer will be deleted.)

c.

Click the drop-down handle for the text box in the Salesperson Code group header row (column 6, row 2) and select [Cust__Ledger_Entry__Sales__LCY__] from the drop-down list box.

d.

Click twice inside the text box to select the contents. (The selected context will become blue.)

e.

Right-click the selected text and select Summarize by, Sum.

f.

The text box now contains the expression: [Sum(Cust__Ledger_Entry__Sales__LCY__)].

g.

Repeat steps c through f for the Cust__Ledger_Entry__Profit__LCY__ expression (column 7, row 2).

Have the Country/Region Code Group Totals Displayed in the Header. a.

Right-click the row handle for the Customer__Country_Region_Code_ group footer.

b.

Select Delete Rows. (The footer will be deleted.)

c.

Click the drop-down handle for the text box in the Customer__Country_Region_Code_header row (column 6, row 3) and select [Cust__Ledger_Entry__Sales__LCY__] from the dropdown list box.

d.

Click twice inside the text box to select the contents. (The selected context will become blue.)

e.

Right-click the selected text and select Summarize by, Sum.

f.

The text box now contains the expression: [Sum(Cust__Ledger_Entry__Sales__LCY__)].

g.

Repeat steps c through e for the Cust__Ledger_Entry__Profit__LCY__ expression. (column 7, row 3)

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

Module 2: Interactive Features 6.

7.

8.

Have the Customer No Group Totals Displayed in the Footer. a.

Click the drop-down handle for the text box in the Customer__No__ footer row (column 6, row 8) and select [Cust__Ledger_Entry__Sales__LCY__] from the drop-down list box.

b.

Click twice inside the text box to select the contents. (The selected context will become blue.)

c.

Right-click the selected text and select Summarize by, Sum.

d.

The text box now contains the expression: [Sum(Cust__Ledger_Entry__Sales__LCY__)].

e.

Repeat steps a through c for the Cust__Ledger_Entry__Profit__LCY__ expression. (column 7, row 8)

Have the _Document_Type Group Totals Displayed in the Header. a.

Click the drop-down handle for the text box in the Cust__Ledger_Entry__Document_Type_ header row (column 6, row 5) and select [Cust__Ledger_Entry__Sales__LCY__] from the drop-down list box.

b.

Click twice inside the text box to select the contents. (The selected context will become blue.)

c.

Right-click the selected text and select Summarize by, Sum.

d.

The text box now contains the expression: [Sum(Cust__Ledger_Entry__Sales__LCY__)]

e.

Repeat steps a through e for the Cust__Ledger_Entry__Profit__LCY__ expression. (column 7, row 5)

Add an Information Label to the Customer No. Footer Row. a.

In the group footer row for group 3, select the fifth cell. (column 5, row 8)

b.

Right-click the cell and select Expression.

c.

In the Build an expression using Visual Basic language syntax, after the equal (=) sign, enter "Total for Customer ", followed by the ampersand (&) sign. (Be sure to include the double quotes and add a space before and after the ampersand.)

d.

In the Category list, select Fields (DataSet_Result).

e.

In the Field list, double-click Customer__No__

f.

The resulting expression should now be:

="Total for Customer " & Fields!Customer__No__.Value

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

2 - 81

Reporting in Microsoft Dynamics® NAV 2013

9.

g.

Click OK to close the Expression window.

h.

In the Properties window for the cell (column 5, row 8), set the TextAlign property to Right.

i.

In the Properties window for the cell, set the FontWeight property (in the Font property collection) to Medium.

Change Background Colors of the Headers and Footers. a.

Click the row-handle for the first group header row.

b.

In the Properties window, set the BackgroundColor to LightCoral.

c.

Click the row-handle for the second group header row.

d.

In the Properties window, set the BackgroundColor to LightGreen.

e.

Click the row-handle for the third group header row.

f.

Press the CTRL key, and keep it pressed down, while you click the row-handle for the corresponding group footer row. (Now two rows are selected, the fourth and last row)

g.

In the Properties window, set the BackgroundColor to LightSkyBlue.

h.

Click the row-handle for the fourth group header row. (fifth row)

i.

In the Properties window, set the BackgroundColor to Yellow.

10. Add the Customer Name to the Customer Group Header. a.

In the textbox in column 4, row 4: select the Customer_Name field in the dataset.

11. Run the Report.

2 - 82

a.

Exit Visual Studio.

b.

Save and import the RDLC changes.

c.

Save and compile the report in the Report Designer.

d.

Run the report from the Start, Run menu.

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

Module 2: Interactive Features

Lab 2.2: Adding Interactive Sorting Scenario After implementing the Visibility options, Mort presents the new report to Kevin. Kevin asks Mort to duplicate the report, but with different sorting. Mort decides to implement interactive sorting for a number of fields, so that Kevin can change the sorting of the data without having to run the report again.

Objectives In this lab you will add Interactive Sorting for a number of fields.

Exercise 1: Add Interactive Sorting for a Number of Fields Task 1: Add Interactive Sorting High Level Steps 1.

Add interactive sorting for the following fields:

2.

Add Interactive Sorting for the Salesperson Code Field.

3.

Add Interactive Sorting for the Country/Region Code Field.

4.

Add Interactive Sorting for the Customer No. Field.

5.

Add Interactive Sorting for the Document Type Field.

6.

Add Interactive Sorting for the Profit (LCY) Field.

7.

Run the Report.

Detailed Steps 1.

2.

Add interactive sorting for the following fields: a.

Salesperson Code

b.

Country Region Code

c.

Customer No.

d.

Document Type

e.

Posting Date

f.

Profit (LCY)

Add Interactive Sorting for the Salesperson Code Field. a.

Open report 123456700 in Visual Studio Report Designer.

b.

Select the first cell in the table header row.

c.

Right-click the cell and select Text Box Properties.

d.

On the Interactive sorting Tab, enter a check mark in Enabled interactive sorting on this text box.

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

2 - 83

Reporting in Microsoft Dynamics® NAV 2013

3.

4.

5.

2 - 84

e.

In the Sort by expression field, select [Customer__Salesperson_Code_].

f.

In Choose what to sort:, select Groups, Group1.

g.

Click OK to close the Text Box Properties window.

Add Interactive Sorting for the Country/Region Code Field. a.

Open the report in Visual Studio Report Designer.

b.

Select the second cell in the table header row.

c.

Right-click the cell and select Properties.

d.

On the Interactive sorting Tab, enter a check mark in Enabled interactive sorting on this text box.

e.

In the Sort by expression field, select [Customer__Country_Region_Code_].

f.

In Choose what to sort:, select Groups, Group2.

g.

Click OK to close the Text Box Properties window.

Add Interactive Sorting for the Customer No. Field. a.

Open the report in Visual Studio Report Designer.

b.

Select the third cell in the table header row.

c.

Right-click the cell and select Properties.

d.

On the Interactive sorting Tab, enter a check mark in Enabled interactive sorting on this text box.

e.

In the Sort by expression field, select [Customer__No__].

f.

In Choose what to sort:, select Groups, Group3.

g.

Click OK to close the Text Box Properties window.

Add Interactive Sorting for the Document Type Field. a.

Open the report in Visual Studio Report Designer.

b.

Select the fifth cell in the table header row.

c.

Right-click the cell and select Properties.

d.

On the Interactive sorting Tab, enter a check mark in Enabled interactive sorting on this text box.

e.

In the Sort by expression field, select [Cust__Ledger_Entry__Document_Type_].

f.

In Choose what to sort:, select Groups, Group4.

g.

Click OK to close the Text Box Properties window.

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

Module 2: Interactive Features 6.

7.

Add Interactive Sorting for the Profit (LCY) Field. a.

Open the report in Visual Studio Report Designer.

b.

Select the last cell in the table header row, the cell containing the caption for the Profit LCY field.

c.

Right-click the cell and select Properties.

d.

On the Interactive sorting Tab, enter a check mark in Enabled interactive sorting on this text box.

e.

In the Sort by expression field, select [Cust__Ledger_Entry__Profit__LCY__].

f.

In Choose what to sort:, select Detail rows.

g.

Click OK to close the Text Box Properties window.

Run the Report. a.

Exit Visual Studio.

b.

Save and import the RDLC changes.

c.

Save and compile the report in the Report Designer.

d.

Run the report from the Start, Run menu.

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

2 - 85

Reporting in Microsoft Dynamics® NAV 2013

Lab 2.3: Adding a Document Map Scenario During his conversations with Kevin, Mort notices that Kevin focuses his attention mostly on the report navigation. Meanwhile, Mort has learned about document maps, a built-in feature of Microsoft SQL Server Reporting Services. With this feature, users can quickly navigate through the contents of a report, so Mort decides to implement a document map in the Sales by Salesperson report.

Objectives In this lab, you will add a document map to the report. You will also learn how to add a named document map.

Exercise 1: Implement a Document Map in the Sales by Salesperson Report Task 1: Add the Document Map High Level Steps 1.

Add a document map to the report with the following specifications:

2.

Define a Name for the Data Region Control in the Document Map.

3.

Add Fields to the Document Map.

4.

Run the Report.

Detailed Steps 1.

2.

2 - 86

Add a document map to the report with the following specifications: a.

The document map should be labeled "Sales by Salesperson".

b.

The document map should contain the following data levels: Salesperson Code, Country Code, Customer Name.

Define a Name for the Data Region Control in the Document Map. a.

Open the RDLC layout of report 123456700 in Visual Studio Report Designer.

b.

In the Properties window select Tablix1.

c.

Enter "Sales by Salesperson" in the DocumentMapLabels property. This will appear as a label for the current table (data region control) in the report. This is convenient if the report contains several tables with a document map.

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

Module 2: Interactive Features 3.

4.

Add Fields to the Document Map. a.

On the Row Groups Tab, select the group1 and click Group Properties. The Grouping Properties window will appear.

b.

On the Advanced Tab, select [Customer__Salesperson_Code_] in the Document map field.

c.

Click OK to close the Grouping Properties window.

d.

On the Row Groups Tab, select the group2 and click Properties. The Grouping Properties window will appear.

e.

On the Advanced Tab, select [Customer__Country_Region_Code_] in the Document map field.

f.

Click OK to close the Grouping Properties.

g.

On the Row Groups Tab, select the group3 and click Properties. The Grouping Properties window will appear.

h.

On the Advanced Tab, select [Customer__No__] in the Document map label field.

i.

Click OK to close the Grouping Properties window.

Run the Report. a.

Exit Visual Studio.

b.

Save and import the RDLC changes.

c.

Save and compile the report in the Report Designer.

d.

Run the report from the Start, Run menu.

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

2 - 87

Reporting in Microsoft Dynamics® NAV 2013

Lab 2.4: Adding Pictures to a Report Scenario Michael, the Account Manager, must visit with a new customer. To give the customer advanced information, Michael wants to provide the customer with an Item Catalog. Michael arranges a meeting with Mort to explain the specifications of the Item Catalog. The report should have a header (printed on all the pages). Apart from the report title, the header should contain the CRONUS company logo as an embedded picture. Additionally, the basic company information such as, company name, address, postal code, city, country and value added tax (VAT) Registration No. should be included. The list should also include pictures of the items. However, because not all items have pictures, you will include the picture as a hidden field that can be made visible when the user clicks the Item No.

Objectives In this lab, you will work with pictures. You will use embedded images and database pictures. Additionally, you will add a report header and add data fields to the header.

Exercise 1: Create an Item Catalog Report Task 1: Add Images to the Report High Level Steps 1.

Create an Item Catalog report with the following specifications:

2.

Import the Object.

3.

Export the Company Logo from the Demonstration Database.

4.

Create the Table in the Report Layout.

5.

Set the Format for the Unit Price Field.

6.

Set the Format for the Inventory Field.

7.

Change the Layout of the Table Header Cells.

8.

Add the Picture Field to the Table.

9.

Set the Visibility for the Picture Field.

10. Embed the Company Logo Picture in the Report. 11. Add a Page Header Section to the Report. 12. Add the Report Title to the Page Header. 13. Add Text Boxes for the Company Information to the Page Header. 14. Run the Report.

2 - 88

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

Module 2: Interactive Features Detailed Steps 1.

2.

3.

4.

Create an Item Catalog report with the following specifications: a.

The body contains the following item information: No., Description, Base Unit of Measure, Unit Price, Inventory and Picture.

b.

The Picture can be made visible by clicking the Item No.

c.

The header contains the report title, basic company information (company name, address, postal code, city, country and VAT Registration No.) and the Cronus logo (as an embedded picture). The header must appear on all the pages.

Import the Object. a.

Open the Microsoft Dynamics NAV 2013 demonstration database.

b.

Select Tools, Object Designer to open the Object Designer.

c.

Select File, Import.

d.

Browse to report R123456724.

e.

Click OK to start the import.

f.

In the dialog box, choose to open the Import Worksheet window.

g.

In the Action column, verify that the action is set to Create.

h.

Click OK to import the object in the database.

Export the Company Logo from the Demonstration Database. a.

Open the CRONUS International Ltd. company in Microsoft Dynamics NAV.

b.

In the Object Designer, run page 1, Company Information.

c.

Right-click Picture, Save As.

d.

Save the company logo as a bitmap (cronus.bmp) on the Windows desktop.

e.

Close the Company Information window.

Create the Table in the Report Layout. a.

Open report 123456724 in Visual Studio Report Designer.

b.

Add a table to the Body section.

c.

Add two columns to the table.

d.

In the Website Data Sources window, select No_Item and drag it to the first cell in the table detail row.

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

2 - 89

Reporting in Microsoft Dynamics® NAV 2013

5.

e.

In the Website Data Sources window, select Description_Item and drag it to the second cell in the table detail row.

f.

In the Website Data Sources window, select BaseUnitofMeasure_Item and drag it to the third cell in the table detail row.

g.

In the Website Data Sources window, select UnitPrice_Item and drag it to the fourth cell in the table detail row.

h.

In the Website Data Sources window, select Inventory_Item and drag it to the fifth cell in the table detail row.

Set the Format for the Unit Price Field. a.

On the table detail row, select the cell containing the [Unit_Price_Item].

b.

Right-click the cell and select Properties.

c.

On the properties window, select Number tab, click Custom in right panel, enter below format code in Expression window:

=Fields!UnitPrice_ItemFormat.Value. d. 6.

Click OK to close the Text Box Properties window.

Set the Format for the Inventory Field. a.

On the table detail row, select the cell containing the [Inventory_Item].

b.

Right-click the cell and select Properties.

c.

On the Format Tab, in the Format Code field, select the proper format code using the Expression window:

=Fields!Inventory_ItemFormat.Value d. 7.

8.

2 - 90

Click OK to close the Text Box Properties window.

Change the Layout of the Table Header Cells. a.

Click the row handle for the table header row.

b.

Set the FontWeight property (in the Font collection) to Bold.

c.

Set the VerticalAlign property to Bottom.

Add the Picture Field to the Table. a.

Add a column to the right side of the table.

b.

From the Toolbox window drag an Image control to the new column.

c.

In the Image Properties window, set the Select image source property to Database.

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

Module 2: Interactive Features

9.

d.

In the Image Properties window, set the Use this image property to [Picture_Item].

e.

In the Image Properties window, set the Use this MIME Type property to image/bmp.

Set the Visibility for the Picture Field. a.

In the Properties window, in the Visibility property collection, set the Hidden property to True.

b.

In the Properties window, in the Visibility property collection, set the ToggleItem property to No_Item.

10. Embed the Company Logo Picture in the Report. a.

In the Report Data Tab, select the Images folder.

b.

Right-click and select Add Image.

c.

Browse to the Windows desktop and select cronus.bmp.

d.

Click OK to import the picture in the report.

11. Add a Page Header Section to the Report. a.

In the Report menu, select Add Page Header in case there is none present in the report.

b.

In the Images folder, select the CRONUS image you just added and drag it onto the page header.

c.

In the Image Properties window that opens, click the OK button.

12. Add the Report Title to the Page Header. a.

In the Toolbox window, select the Text box control and insert it in the top left corner of the page header section.

b.

Select the Text box control.

c.

Set the value property to "Item Catalog".

d.

Set the FontSize property to 18pt.

e.

Set the Color property to RoyalBlue.

13. Add Text Boxes for the Company Information to the Page Header. a.

Add six new text boxes to the Page Header.

b.

Select the CompanyName in the Report Dataset and drag it onto the first text box.

c.

Select the CompanyAddress in the Report Dataset and drag it onto the next text box.

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

2 - 91

Reporting in Microsoft Dynamics® NAV 2013 d.

Select the CompanyPostCode in the Report Dataset and drag it onto the next text box.

e.

Select the CompanyCity in the Report Dataset and drag it onto the next text box.

f.

Select the CompanyCountryRegionCode in the Report Dataset and drag it onto the next text box.

g.

Select the CompanyVATRegistrationNumber in the Report Dataset and drag it onto the next text box.

14. Run the Report.

2 - 92

a.

Exit Visual Studio.

b.

Save and import the RDLC changes.

c.

Save and compile the report in the Report Designer.

d.

Run the report from the Start, Run menu.

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

Module 2: Interactive Features

Module Review Module Review and Takeaways In this module you learned how to work with the enriched functionalities of the new reporting solution. This module also described the different types of headers and footers and how to activate them. Additionally, you learned how to use interactive sorting, visibility options, document maps and different types of images. The most important aspects covered in this module are: •

Adding groups in a tablix data region.



Using images in a report.



The difference between print preview and print layout.



Apply visibility options, interactive sorting and document maps.

Test Your Knowledge Test your knowledge with the following questions. 1.

Which header sections are not supported by Visual Studio Report Designer? ( ) Page Header ( ) Group Header ( ) Transport Header ( ) Table Header

2.

Which properties are not supported by Visual Studio Report Designer? ( ) FixedRowHeaders ( ) RepeatColumnHeaders ( ) Keeptogether ( ) PlaceInBottom ( ) LayoutDirection

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

2 - 93

Reporting in Microsoft Dynamics® NAV 2013 3.

In which windows can you delete a group? ( ) Properties window ( ) Table Properties window ( ) Row Groups window ( ) Header Properties window ( ) Toolbox window

4.

Which is not a valid option for the Source property of an image control? ( ) Internal ( ) External ( ) Embedded ( ) Database

5.

Which controls cannot be added to a Page Header section? ( ) Chart ( ) Line ( ) Text box ( ) Rectangle ( ) Image

2 - 94

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

Module 2: Interactive Features 6.

Which of the following statements is true? ( ) Database images can only be visualized in the Report Body Section ( ) Database images can only be visualized in the Report Header or Footer Section ( ) Database images can be visualized in all sections of the report ( ) None of the answers is correct

7.

Which properties can be used to set the background and the foreground color of a control? ( ) BackgroundColor and ForegroundColor ( ) BackgroundColor and TextColor ( ) BackgroundColor and Color ( ) BackgroundColor and CellColor

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

2 - 95

Reporting in Microsoft Dynamics® NAV 2013

Test Your Knowledge Solutions Module Review and Takeaways 1.

Which header sections are not supported by Visual Studio Report Designer? ( ) Page Header ( ) Group Header (√) Transport Header ( ) Table Header

2.

Which properties are not supported by Visual Studio Report Designer? ( ) FixedRowHeaders ( ) RepeatColumnHeaders ( ) Keeptogether (√) PlaceInBottom ( ) LayoutDirection

3.

In which windows can you delete a group? ( ) Properties window ( ) Table Properties window (√) Row Groups window ( ) Header Properties window ( ) Toolbox window

4.

Which is not a valid option for the Source property of an image control? (√) Internal ( ) External ( ) Embedded ( ) Database

2 - 96

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

Module 2: Interactive Features 5.

Which controls cannot be added to a Page Header section? (√) Chart ( ) Line ( ) Text box ( ) Rectangle ( ) Image

6.

Which of the following statements is true? ( ) Database images can only be visualized in the Report Body Section ( ) Database images can only be visualized in the Report Header or Footer Section (√) Database images can be visualized in all sections of the report ( ) None of the answers is correct

7.

Which properties can be used to set the background and the foreground color of a control? ( ) BackgroundColor and ForegroundColor ( ) BackgroundColor and TextColor (√) BackgroundColor and Color ( ) BackgroundColor and CellColor

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

2 - 97

Reporting in Microsoft Dynamics® NAV 2013

2 - 98

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

MODULE 3: ADDING CODE TO A REPORT Module Overview When you create reports in Microsoft Dynamics® NAV, start by defining the data model for the report, by filling in the data item(s) in the Report Dataset Designer. In addition to properties, for every data item there are also triggers available. Triggers can contain C/AL code that is executed when the trigger occurs. The report includes the following triggers: •

OnInitReport()



OnPreReport()



OnPostReport()

For every data item that you add in the DataItem designer window the following triggers are available: •

OnPreDataItem()



OnAfterGetRecord()



OnPostDataItem()

The request page of a report has the following triggers: •

Documentation()



OnInit()



OnOpenPage()



OnClosePage()



OnFindRecord(Which : Text) : Boolean



OnNextRecord(Steps : Integer) : Integer



OnAfterGetRecord()



OnNewRecord(BelowxRec : Boolean)



OnInsertRecord(BelowxRec : Boolean) : Boolean



OnModifyRecord() : Boolean



OnDeleteRecord() : Boolean



OnQueryClosePage(CloseAction : Action None) : Boolean



OnAfterGetCurrRecord()

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

3-1

Reporting in Microsoft Dynamics® NAV 2013 The controls on the request page each have the following triggers: •

OnValidate()



OnLookup(VAR Text : Text) : Boolean



OnDrillDown()



OnAssistEdit()



OnControlAddIn(Index : Integer;Data : Text)

In reports, triggers are typically used to perform calculations and to control whether to output sections. You can use triggers to control how data is selected and retrieved in a more complex and effective way than you can achieve by using properties. An RDLC report layout does not contain triggers. Instead, you can use expressions. Expressions are related to properties in RDLC reports. This module will focus on the important features that you must know to be able to develop RDLC reports.

Objectives The objectives are:

3-2



Explain how coding can be used in reports.



Work with expressions.



Learn how to use expressions.



Examine frequently used expressions.



Describe the components of the Sales Invoice report.

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

Module 3: Adding Code to a Report

Using Variables and C/AL Code in a Report The reports built in the previous modules are designed by using the designers, controls and properties. In reports, you can also add code. The code is used for advanced report functionalities that cannot be achieved by using properties. Additionally, the code can be used for retrieving and calculating data, but also for formatting purposes (and dynamically hiding and showing data sections). Code can be written using the C/AL Editor on different levels: •

Report triggers



Data item triggers



Request page triggers



Request page control triggers

Previous modules described how the logical design of a report applies to Report Definition Language Client-side (RDLC) report layouts. If you use code to filter or sort a specific data item, the code will be reflected in the dataset that is generated. But not all code is written on the data item level. Many reports have a request options page that uses options that affect the way a report is printed. Well-known options include the following: Show details, Print amounts in Local Currency, Top X (where X can be a number selected by the user such as Top 5, Top 10), Show Sales (LCY) or Balance (LCY). The information from the Request page is stored in variables that are evaluated in runtime.

Report Triggers In reports, triggers are typically used to perform calculations and verification. You can use triggers to control how data is selected and retrieved in a more complex and effective way than you can achieve by using properties. OnInitReport This trigger is executed before the Request page is run and before any table views or filters are set. This trigger performs any processing that is required before the report is run, such as initializing global variables. It can also stop the report.

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

3-3

Reporting in Microsoft Dynamics® NAV 2013 OnPreReport This trigger executes after the Request page is run. The table views and filters for the report data items are set while this trigger is executed. As this trigger is executed after the Request page is processed, you have access to any filters the user has set. If you want to print the settings of these filters in the report, you can retrieve them by using the function: String := Record.GETFILTERS and then by using the text string as the source expression for a control in a section of the report. OnPostReport This trigger is executed after all data items are processed. The trigger is not run if the report is stopped manually or if you are using the QUIT function before processing has concluded. Because this trigger is executed after the report is processed, you can use it to inform users about the result of the report run. Additionally, because this trigger is executed before the End Write Transaction, you can also give the user the opportunity to roll back changes to the database by leaving the report that has the QUIT; function. OnPreDataItem This trigger is executed before a data item is processed, and after the associated variable is initialized and table views and filters are set. You can use this trigger to add more filtering beyond what is established by the DataItemLink property (Reports) or DataItemTableView property. For example, use this trigger if you have to filter an indented data item based on the result of a calculation. Use the SETRANGE or SETFILTER function to add more delimiters. OnPostDataItem This trigger executes after the last record in the data item is processed but before the OnPostReport trigger is executed, if it is the last data item of the report. Use this trigger to perform any cleanup or post processing that is required after a data item is processed. For example, if you create a nonprinting report where records are updated, you can update all the records with the modification date as follows: MODIFYALL("Modification Date",TODAY);

3-4

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

Module 3: Adding Code to a Report OnAfterGetRecord Use this trigger to perform any processing that is required, based on the values in the fields of the individual records of a data item. If the record contains FlowFields, you can put CALCFIELDS statements in this trigger to have them calculated. Although it is typically easier to use the CalcFields property to have it done automatically, there are situations where you have to use this trigger to perform the calculation explicitly. For example, if you apply FlowFilters based on the context of the report to the FlowFields inside this trigger, you must recalculate the FlowFields after you have applied the FlowFilters. Another example is when you must retrieve information from a table that is external to the report. This is the situation when the records of a data item contain fields that are foreign keys (meaning the fields that are primary keys in other tables), and you want to extract additional information from the related tables. For example, in a report, the records in a data item might contain a field that has a Vendor code. However, you want to print the full name and address of the vendor. You use this trigger to retrieve the information so that you can print it in your report.

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

3-5

Reporting in Microsoft Dynamics® NAV 2013 Trigger Execution Order When you run a report, the report triggers are called in a specific order. The ReportTriggersExecution figure describes the order in which report triggers are executed.

FIGURE 3.1: REPORT TRIGGERS EXECUTION ORDER When you start the report run, the OnInitReport trigger is called. If the OnInitReport does not end the processing of the report, then the request page for the report is run, if it is defined. The page triggers for the request page are called. On the request page, you select the options that you want for this report. You can also decide to cancel the report run. If you decide to continue, then the OnPreReport trigger is called. At this point, no data is processed. When the OnPreReport trigger is executed, the first data item is processed if the processing of the report is not ended in the OnPreReport trigger. When the first data item is processed, the next data item is processed in the same manner. When there are no more data items, the OnPostReport trigger is called to do any necessary post processing, for example, removing temporary files.

3-6

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

Module 3: Adding Code to a Report Note: If you define two functions that have the same name, one defined in a report and the other in a table that is referenced by the report, you cannot start the function that is defined in the report directly. By default, a call to the function invokes the function that is defined in the table. This behavior occurs when the function is called from a source expression or a trigger. How a Data Item is Processed Before the first record is retrieved, the OnPreDataItem trigger is called, and after the last record is processed, the OnPostDataItem trigger is called. Between these two triggers, the data item records are processed. Processing a record means executing the record triggers and outputting data. After a record is retrieved from the data item, the OnAfterGetRecord (Data Items) trigger is called. If there is an indented data item, then the records in this data item are processed. When there are no more records to be processed in a data item, control returns to the point from which processing is initiated. For an indented data item, this means the next record of the data item on the next highest level. If the data item is already on the highest level, then control returns to the report.

Check the Value of Printed Variables In a RDLC report layout, when a Boolean value appears on a report, the value is printed as "true" or "false" in the target language. In some cases, you might want to change the printed value of a Boolean variable in a RDLC report layout to "yes" or "no" instead of "true" or "false." This can be performed in two ways: either you change the SourceExpr property of the text box that displays the Boolean variable to FORMAT(BooleanVariable), or you set the Value property of the text box in the RDLC report layout to an expression such as =IiF(Fields!BooleanVariable.Value = False, "No", "Yes"). The same applies to date values. When you create a RDLC layout for a report, you must modify date values so that they are formatted correctly. You can use a similar procedure for the boolean variables to verify or change the format of a date. You can set the format in the report by using the FORMAT() function, or by using an expression to define the format of the date.

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

3-7

Reporting in Microsoft Dynamics® NAV 2013 Best Practice: In the C/AL code, you can use both the numeric value and the text representation to check the value that is selected for an option variable. A RDLC report layout does not provide the following functionality: strings will be handled as normal strings. It is recommended that you work with the numeric value of the option variables in the RDLC report layouts so that multilanguage functionality will not be an issue.

Demonstration: Using Option Strings in Multilanguage Implementations In a RDLC report layout, an option variable is handled as a typical string, not an option string. If you have a Multilanguage application, handling the option as a normal string will cause problems in the displayed report. You must manually convert the option string to an integer variable and then use the integer variable in the RDLC report layout. An example of a report that uses an option variable that is converted to an integer variable is report 12345671, Customer Top 10 List. The request page has an option variable, ShowType. You can use this option variable to select to display either Sales (LCY) or Balance (LCY) in the report. The value of the ShowType variable is assigned to an integer variable, ShowTypeNo, in the OnAfterGetRecord trigger.

Demonstration Steps 1.

Assign the option string to an integer variable. a.

In the development environment, on the Tools menu, click Object Designer.

b.

In Object Designer, click Report, select the report that you want to modify, and then click Design.

c.

On the View menu, select C/AL Globals.

d.

In the C/AL Globals window, on the Variables tab, there’s an integer variable. You use this variable for the integer value of an existing option variable. For example, in report 12345671, Customer -Top 10 List 2, you have an option variable on the request page named ShowType. On the report, there’s integer variable called ShowTypeNo.

e.

3-8

In the C/AL Editor, there’s a line of code in the OnAfterGetRecord trigger of the Customer Data Item to assign the option string to an integer value.

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

Module 3: Adding Code to a Report For example, in report 12345671, you have the following line of code. ShowTypeNo := ShowType;

2.

f.

In Report Dataset Designer, add a Column with ShowTypeNo as the value of the Data Source field.

g.

On the File menu, select Save.

h.

In the Save window, select the Compiled check box, and then click OK.

Use the integer variable instead of the option string in the layout. a.

In Object Designer, click Report, select the report that you want to modify, and then click Design.

b.

On the View menu, select Layout.

c.

In Microsoft Visual Studio, in the Report.rdlc file, use the integer variable instead of the option variable, such as in expressions.

In report 111, the ShowTypeNo integer variable is used in expressions on the bar chart and the pie chart.

Demonstration: Change the Printed Value of a Boolean Field. In a RDLC report layout, when a Boolean value appears on a report, the value is printed as "True" or "False" in the target language. In some cases, you might want to change the printed value of a Boolean variable or field in a RDLC report layout. You can change the value to "Yes" or "No" instead of "True" or "False".

Demonstration Steps 1.

Change the printed value of a Boolean field. a.

In the development environment, on the Tools menu, click Object Designer.

b.

In Object Designer, click Report, select the report for which you want to change the printed values of Boolean variables or fields, and then click the Design button.

c.

In Report Dataset Designer, find the column for the Boolean variable or field that you want to change.

d.

In the Data Source field, change the to FORMAT().

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

3-9

Reporting in Microsoft Dynamics® NAV 2013 e.

For example, in report 12345671 you could apply this for the field Customer.Blocked.

f.

On the File menu, select Save.

g.

In the Save window, select the Compiled check box, and then click OK.

Demonstration: Format Decimal Values When you create RDLC layout for a report, a format variable is created for each decimal variable. The format information from the Column properties in Report Dataset Designer is stored in the format variable. Decimal values are formatted in the RDLC layout by using the format variable. If you create controls that use decimal values in a RDLC report layout, then in Visual Studio Report Designer, you must manually specify to use the format variable for the formatting.

Demonstration Steps 1.

3 - 10

Format decimal values. a.

In the development environment, on the Tools menu, click Object Designer.

b.

In Object Designer, select Report, select a report that you want to modify, and then click Design.

c.

On the View menu, select Layout.

d.

In Visual Studio, in the report.rdlc file, right-click the text box that displays a decimal value, and then select Text Box Properties.

e.

In the Text Box Properties window, select the Number tab.

f.

In the Category list, select Custom, and then click the function button (fx) next to the custom format field.

g.

In the Expression window, click Fields (DataSet_Result), select the format variable from the list, and then click OK.

h.

For example, if the Value field on the General tab is =Fields!Customer__Sales__LCY__.Value, then the expressions for the format on the Number tab should be =Fields!Customer__Sales__LCY__Format.Value.

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

Module 3: Adding Code to a Report Demonstration: Format Date Values You can modify date values in Report Dataset Designer to specify how they are formatted in the layout of a report.

Demonstration Steps 1.

Format date values. a.

In the development environment, on the Tools menu, click Object Designer.

b.

In Object Designer, click Report, select a report that you want to modify, and then select Design.

c.

In Report Dataset Designer, in the Data Source field of a Column that contains a date, use the FORMAT function that has the date. For example, instead of entering TODAY in the Data Source field, enter FORMAT(TODAY,0,4).

d.

Use the parameters of the FORMAT function to specify the length and the exact format that you want for the date.

e.

On the File menu, click Save.

f.

In the Save window, select the Compiled check box, and then click OK.

Working with Report Expressions Expressions are widely used in a report for various purposes. They can be used for data manipulation (retrieve, calculate, format, group, sort and filter data) and formatting. Expressions are used to provide dynamic flexibility for controlling the content and appearance of a report. In most cases, expressions are used to obtain the following kinds of functionality in your report: •

Aggregations on data to show the sum, average, percentage, or product of a particular rowset.



Conditional formatting, where text or background formatting changes based on logic that you define.



Conditional text, where a report title varies, depending on who is running the report.



Concatenated text from multiple dataset fields and constants.



Data filtering (after it is retrieved from the data source).



Data grouping and sorting.



Dynamic page header and page footer content.

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

3 - 11

Reporting in Microsoft Dynamics® NAV 2013 On the report design surface, expressions appear as simple or complex expressions. Simple expressions contain a reference to a single dataset field or built-in field. Simple expressions are created for you automatically (for example, when dragging a field from a dataset onto a text box), or you can type them directly into a data region cell or text box on the design surface. Complex expressions can contain multiple built-in references, operators, and function calls combined with simple expressions. An expression is written in Microsoft® Visual Basic®. An expression begins with an equal sign (=) and consists of references to dataset fields, constants, operators, functions, and other built-in report collections. During report processing, each expression evaluates to a single value that replaces the expression when a report is rendered. Knowing how to create and use expressions is a fundamental skill that will help you create rich full-featured reports.

How to Create Expressions You can create expressions in a report definition by using the Expression window, or by typing the expression syntax directly into a text box, a property in the Properties window, or a group, sort and filter expression field. Using the Expression window has many advantages over manually entering the expressions. Other than a large work area, it offers context-sensitive global collection item choices, statement completion, and syntax checking. Expressions are created by using Microsoft Visual Basic language syntax.

3 - 12

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

Module 3: Adding Code to a Report The Expression Editor When you open the Expression window, the following dialog box appears.

FIGURE 3.2: THE EXPRESSION WINDOW The Expression window can be used to add and edit expressions. It is divided into a number of panes. The top pane, the Expression pane, shows the current expression for the selected text box or property. You can edit the expression in the pane by using the keyboard and by double-clicking items in the bottom panes. The bottom middle pane, the Item pane, contains all items that are available in the selected category. The contents of the pane are updated when a new category is selected in the Category pane. For example, the Globals category contains items such as ExecutionTime, UserId and Language. At the right side you can have one large pane, the Field pane, or two smaller panes (the Description and the Example pane). Which panes appear depends on the selected Category. The Field pane contains all elements that are available in the selected Item and Category. The contents of the Field pane are updated when you select a new Item. If the selected Item has no fields, the Field pane will be replaced by the Description and Example panes. The Description pane shows a description of the selected Item. However, the Example pane displays an example of the selected item.

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

3 - 13

Reporting in Microsoft Dynamics® NAV 2013 For example, when you select the Program Flow category (under Common Functions), the Item category will show the three functions in the category. The Description pane will show a small description of the selected Item, and the Example pane shows the syntax of the selected function. When you build an expression, you can double-click any element in the bottom panes to have it inserted automatically in the Expression pane. As the Expression pane suggests, you can build additional expressions by using Microsoft Visual Basic language syntax. The Expression pane supports features such as IntelliSense, statement completion, colored syntax and syntax checking so that you can easily detect syntax errors. You can move and resize the Expression Editor to have a larger work surface. In some windows (for example, on the Sorting tab in the Table Properties window) you can create multiple expressions that will be combined during report processing. However, you can use the Expression window to edit only one expression at a time. Accessing the Expressions Window The Expression editor can be accessed in various ways, depending on the current position in the Visual Studio Report Designer. You can open the Expression Editor for the following items:

3 - 14



Text box on a report



Property in the Properties page



Groups tab on data region properties



Sorting tab on data region properties



Filter tab for datasets, data regions, or data region groupings



Document map label on a data region group



Parent group on a data region group

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

Module 3: Adding Code to a Report On the design surface, you can right-click any text box control and select Expression, as is shown in the Expression Shortcut In Text Box figure.

FIGURE 3.3: EXPRESSION SHORTCUT IN TEXT BOX WINDOW Several properties in the Properties window, such as Visibility, BackgroundColor and Value, support both fixed options and expressions as a first option in the drop-down list. Select in the drop-down list to enter an expression in the Value column for a property.

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

3 - 15

Reporting in Microsoft Dynamics® NAV 2013

FIGURE 3.4: EXPRESSION SHORTCUT IN BACKGROUNDCOLOR PROPERTY WINDOW Expressions can also be entered in various dialog boxes such as the Grouping and Sorting Properties and the Tablix Properties window. In these windows, expressions can be either selected directly from a drop-down list, or they can be entered by clicking the fx button to set specific properties. For example, in the Table Properties window, on the General tab, the fx button is available to define Tooltips.

Valid Expression References The following table shows the types of references that you can include in a report expression. The table indicates which of these references are built-in, and which references, you must identify to the report processor so that the function calls can be resolved during report processing. Items Reporting Functions

3 - 16

Description of functions and how to reference them Built-in. Functions that provide aggregate values on report items, and other utility functions that support aggregation. The Aggregate implementation is supplied by each data provider.

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

Module 3: Adding Code to a Report Items Reporting Collections

Description of functions and how to reference them Built-in. •

Globals



User



Fields



ReportItems



Datasets



Parameters

Custom Code

Built-in. Add your Visual Basic code through the Report Properties menu, Code tab. You can define public constants, variables, subroutines, and functions for your use in each report definition.

Visual Basic Runtime Library

Built-in.

System.Math

Built-in.

System.Convert

Built-in.

.NET Framework (common language runtime) Classes

Add fully qualified references in your expression. For example, System.Text.StringBuilder

In addition to the use of the built-in functions, to add more functions, you can add code or external references to your report. To add custom code to your report, select Report, and then select Report Properties in Visual Studio Report Designer. On the Code tab, you can add the custom code (variables, functions, procedures, and so on) to enrich your report.

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

3 - 17

Reporting in Microsoft Dynamics® NAV 2013 When you open Visual Studio Report Designer to create a report, several functions are automatically added to the Code tab.

FIGURE 3.5: THE CODE TAB OF THE REPORT PROPERTIES WINDOW The functions that are added all relate to the presentation and formatting of data. Although you can add any code to the report by using the Code tab, it is recommended that you do not include code that is part of the report's business logic. Expression always start with the "=" sign. This indicates that the statement following the equal sign is an expression that will be evaluated by the reporting engine. Most expressions consist of a single constant value. For example, the FontName property of a text box can have several constant values, such as Arial, Tahoma, Verdana, and so on. The Width property is less restrictive: the values are not predefined. You can also use a combination of functions, variables and constants to build a more complex expression. To refer to a collection or element from an expression, use the standard Visual Basic syntax. For example, to refer to the value of a specific field (in the Fields collection), use the =Fields("FieldName").Value expression. An alternative way to reference the same value is to use =Fields!FieldName.Value. In this case the (parent) collection and the (child) element are concatenated by an exclamation mark. An element and its properties are always separated by a "." (period).

3 - 18

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

Module 3: Adding Code to a Report Syntax errors are detected and indicated automatically. However, syntax errors do not prevent you from importing the RDLC data into Microsoft Dynamics NAV. When you try to save and compile the report in the Object Designer, some errors in the RDLC report layout might be indicated. For example, if an incorrect syntax for the IIF() statement is used, or if the Value property of a text box in the Page Header section is set to a data field from the dataset, you will receive an error message. Other errors might appear when the report is run. When you use Visual Studio Report Designer, you can also check for errors. In the Build Menu, select Build Solution. The report is parsed for syntax errors and if any are found a message is displayed at the bottom of the window in the Error List. The Error List in Visual Studio Report Designer figure shows an example.

FIGURE 3.6: ERROR LIST IN VISUAL STUDIO REPORT DESIGNER SCREEN SHOT In the Error List in Visual Studio Report Designer figure, the error indicates a typing error in the Value expression for the field Name_Customer:

Code example =Fields!Name_Cstomer.Value Should be =Fields!Name_Customer.Value Note: Other than the items in the previous table, you can also add custom assemblies and classes to reports. However, only trusted managed assemblies are supported. More information about how to create trusted managed assemblies can be found on: http://msdn.microsoft.com

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

3 - 19

Reporting in Microsoft Dynamics® NAV 2013

Understanding and Using Simple and Complex Expressions The previous lesson described how expressions are widely used in reports for various purposes. Knowing how to create and use expressions is a fundamental skill that will help you create rich full-featured reports. This lesson will describe the different data collections that can be used in expressions.

Understanding Display Text for Expressions Simple expressions use symbols to indicate whether the reference is to a field, a parameter, a built-in collection, or the ReportItems collection. The following table shows examples of display and expression text. Item Dataset fields

Display text example

Expression text example

[Sales]

=Fields!Sales.Value

[SUM(Sales)]

=Sum(Fields!Sales.Value)

[FIRST(Store)]

=First(Fields!Store.Value)

[@Param]

=Parameters!Param.Value

[@Param.Label]

=Parameters!Param.Label

Built-in fields

[&ReportName]

=Globals!ReportName.Value

Literal characters that are used for display text

\[Sales\]

[Sales]

Complex expressions



="Page " & Globals!PageNumber & " of " & Globals!TotalPages

Report parameters

Using Constant Collections in Expressions A constant consists of literal text or text that is predefined. The report processor has access to the predefined constants so that when you include them in an expression, the values they represent are substituted in the expression before it is evaluated.

3 - 20

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

Module 3: Adding Code to a Report The Constants collection is mostly used in simple expressions. Simple expressions are frequently used to set properties throughout the report. The content of the Constant category depends on the selected property. When you select the Color property of a text box, it contains the possible colors. When you select the Hidden property (in the Visibility property collection), the category contains two constants: True and False. Literal Text In an expression, literal text is text that is in double quotation marks. You can also type text directly into a text box without double quotation marks if it is not part of an expression. If the text box value does not begin with an equal sign (=), the text is treated as literal text. The following table shows several examples of literal text in an expression. Constant

Display text

Expression text

Report run at:



="Report run at: " & Globals!ExecutionTime

CRONUS International Ltd.

CRONUS International Ltd.

CRONUS International Ltd.

[Bracketed display text]

\[Bracketed display text\]

[Bracketed display text]

RDL Constants You can use constants defined in Report Definition Language (RDL) in an expression. In the Expression dialog box, constants appear when you create an expression for a report property that only accepts certain valid values, also known as enumerated types. The following table shows two examples. Property

Description

Values

TextDecoration

Specifies special text formatting such as underlining.

Default, None, Underline, Overline, LineThrough

FontStyle

Specifies the style of the font.

Default, Normal, Italic

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

3 - 21

Reporting in Microsoft Dynamics® NAV 2013 Visual Basic Constants You can use constants defined in the Visual Basic run-time library in an expression. The following table shows two examples. Constant vbCrLf

Description The Visual Basic constant for a carriage return followed a new line. For example, the following expression shows the time stamp for report processing and the user on two lines in a single text box: =Globals!ExecutionTime & vbCrLf & User!UserID

DateInterval.Day

The Visual Basic constant that you use to designate the day part of a date time value in a DatePart function call. For example, for the date January 10, 2008, the following function returns the number 10: =DatePart("d",Globals!ExecutionTime)

CLR Constants You can use constants defined in the .NET Framework common language runtime (CLR) classes in an expression. The following table shows an example of a system-defined color. Constant MistyRose

3 - 22

Description When you create an expression for a report property that is based on background color, you can specify a color by name. Valid names are listed in the Expression dialog box.

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

Module 3: Adding Code to a Report Demonstration: Using a Constant in the Report Header Mort is creating a new report. He adds a Page Header to the report and will now add a text box that contains the execution time and user ID. To show both values in one text box he uses the constant VBCRLF.

Demonstration Steps 1.

In the newly added text box, add an expression to show the execution time and user ID: a.

Right-click the text box and select: Expression.

b.

The Expression Designer window opens.

c.

Type the following expression:

=Globals!ExecutionTime & vbCrLf & User!UserID The Expression With A Constant figure shows the expression.

FIGURE 3.7: EXPRESSION WITH A CONSTANT WINDOW

Using Global Collections in Expressions The following global collections can be referenced from expressions: •

Constants



DataSets



DataSources



Fields

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

3 - 23

Reporting in Microsoft Dynamics® NAV 2013 •

Globals



Parameters



ReportItems



User

The following table describes each global collection and explains when you can reference the collection from an expression. Global Collection Fields

Description Represents the collection of fields of the dataset that are available to the report. Available after data is retrieved from Microsoft Dynamics NAV into the dataset.

ReportItems

Represents the collection of text boxes for the report item, such as the text boxes that are contained in a table data region, page header, or page footer. Available during report processing.

User

Represents a collection of data about the user running the report, such as the language setting or the user ID. Always available. User!UserID is frequently used to filter results in reports. User!Language is used to make specific settings dependent on the language of the user.

DataSets

Represents the collection of datasets referenced from the body of a report definition. Does not include data sources used only in page headers or page footers.

Globals

Represents global variables useful for reports, such as the report name or page number. Always available.

Parameters

Represents the collection of report parameters when you use Labels or use the IncludeCaption property.

More detailed information about some frequently used functions is described in the next lesson.

3 - 24

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

Module 3: Adding Code to a Report Using Report Functions in Expressions Report Viewer provides a set of built-in functions that you can include in an expression. Built-in functions include the Microsoft .NET Framework common language runtime (CLR) classes and Visual Basic run-time library functions. For convenience, you can view the most frequently used functions in the Expression dialog box, where they are listed by category: Text, Date and Time, Math, Inspection, Program Flow, Aggregate, Financial, Conversion, and Miscellaneous. Those less typically used functions do not appear in the list but can still be used in an expression. You can use built-in functions within expressions to manipulate the data within report items, properties, and other areas in the report. Built-in functions are used to aggregate data in datasets, data regions, and groups, and return other data. You can use aggregate functions in expressions for any report item. All data that is used for an aggregate calculation must be the same data type. To convert data that has multiple numeric data types to the same data type, use conversion functions such as the following: CInt(), CDbl() or CDec(). The following table describes the aggregate functions that are supported by Reporting Services. Function

Description

Aggregate

Returns a custom aggregate of the specified expression, as defined by the data provider.

Avg

Returns the average of all non-null values from the specified expression.

Count

Returns a count of the non-null values from the specified expression.

CountDistinct

Returns a count of all non-null distinct values from the specified expression.

CountRows

Returns a count of rows within the specified scope.

First

Returns the first value from the specified expression.

Last

Returns the last value from the specified expression.

Max

Returns the maximum value from all non-null values of the specified expression.

Min

Returns the minimum value from all non-null values of the specified expression.

RowNumber

Returns a running count of all rows in the specified scope.

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

3 - 25

Reporting in Microsoft Dynamics® NAV 2013 Function

Description

RunningValue

Uses a specified function to return a running aggregate of the specified expression.

StDev

Returns the standard deviation of all non-null values of the specified expression.

StDevP

Returns the population standard deviation of all non-null values of the specified expression.

Sum

Returns a sum of the values of the specified expression.

Var

Returns the variance of all non-null values of the specified expression.

VarP

Returns the population variance of all non-null values of the specified expression.

Reporting Services provides the following additional aggregate functions that you can use within expressions. Function

Description

InScope

Indicates whether the current instance of an item is within the specified scope.

Level

Returns the current level of depth in a recursive hierarchy.

Previous

Returns the previous instance from the specified scope.

Each aggregate function uses the Scope parameter. This defines the scope in which the aggregate function is performed. A valid scope is the name of a grouping, dataset, or data region. Only groupings or data regions that directly or indirectly contain the expression can be used as a scope. For expressions within data regions, Scope is optional for all aggregate functions. If you are omitting the Scope parameter, the scope of the aggregate is the innermost data region or grouping to which the report item belongs. Information related to Scope includes the following:

3 - 26



Specifying a scope of Nothing sets the scope to the outermost data region to which the report item belongs.



For expressions outside data regions, Scope refers to a data table or business object.



If a report contains more than one dataset, Scope is required.



If a report contains only one dataset and Scope is omitted, the scope is set to the dataset.

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

Module 3: Adding Code to a Report •

The Nothing keyword cannot be specified for report items outside a data region.



The Scope parameter cannot be used in page headers or footers.

Demonstration: Using a Report Function in an Expression The management of Cronus International Ltd. asked Mort to add row numbers to the report 123456711 Resource List2. Mort knows this can be easily performed by using the RowNumber function. He will implement this in the existing report.

Demonstration Steps 1.

Add a row number to report 123456711 Resource – List2: a.

Select Tools, Object Designer to open the Object Designer.

b.

Select File, Import.

c.

Browse to the report R123456711.fob.

d.

Click OK to start the import.

e.

In the dialog box, choose to open the Import Worksheet window.

f.

In the Action column, verify that the action is set to Create.

g.

Click Open to import the object in the database.

h.

In the Object Designer, select report 123456711 Resource – List2 and then click Design.

i.

In the Report Dataset Designer click View, and then select Layout.

j.

In Visual Studio Report Designer, right-click the column header of the first row in the table.

k.

Select Insert Column, Left.

l.

In the newly added column, in the text box on the detail row enter the following expression: =RowNumber(Nothing)

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

3 - 27

Reporting in Microsoft Dynamics® NAV 2013 m. Save and close Visual Studio and then save and close the Report Dataset Designer. n.

Run the report. The result will resemble this:

FIGURE 3.8: REPORT WITH ROWNUMBER WINDOW

Understanding scope The term scope can specify different concepts, depending on the context. The following list describes the different concepts. Scope for report items in report processing When the report data and the report layout are combined at run time, each report item is processed. A Tablix data region is processed from the outside into more restrictive sets of data as the Tablix row groups and column groups are processed. So, a group is contained by a data region. A child group and its siblings are contained by its parent group. For example, a toggle item for a group must be a text box in the same group scope or in any that contains a group scope. Scope for aggregate functions The report processor evaluates each aggregate expression in a named scope or the default scope, as is described here. A named scope can be the name of a dataset, a data region, or a group.

3 - 28

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

Module 3: Adding Code to a Report The default scope depends on the report item property that the report processor is evaluating. For example, the default scope for a Tablix cell in a data region with row and column groups is the innermost row group and column group to which the cell belongs. The default scope for a cell in a table without groups is the details group. On the design surface, a Tablix data region provides visual elements that you can use to help determine a cell's available scopes. Group bars appear before and next to the Tablix data region to show which rows or columns belong to a group. When a cell is selected, group indicators show the active, innermost groups to which the cell belongs. For a text box on the design surface, there is no default scope. You must specify the name of the dataset to use, for example, =First(Fields!Sales.Value,"Dataset1"). When you call a built-in function and specify a named scope, check the function reference to determine which scopes are valid. For example, for Sum, you can specify the default scope or a containing scope. The following scopes list the containing order from outermost (greater) to innermost (reduced) and describe the data that they represent: Report dataset Specifies the report dataset linked to the data region or to a report item in the report body. The data that is used for aggregation is from the report dataset after dataset filter expressions are applied. Data region Specifies data from the data region after data region filter and sort expressions are applied. Group filters are not used when calculating aggregates for data regions. Row and column groups Specifies the data after the group expressions and group filters are applied for the parent group and child groups. For the purposes of identifying scope containment, every parent group contains its child groups. Nested data regions Specifies the data for the nested data region in the context of the cell to which it is added, and after the nested data region filter and sort expressions are applied.

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

3 - 29

Reporting in Microsoft Dynamics® NAV 2013 Row and column groups for the nested data regions Specifies the data after the nested data region's group expressions and group filters are applied. When a built-in function states that you must specify the current scope or a containing scope, you cannot specify a scope that is lower or at the same level in a containment order than the current scope. For example, from a row in a row group that has a child group, you cannot specify the name of the child group as a scope, nor can you specify a sibling row group. You must use the default scope or specify a scope that is higher in the containment order.

Expression Examples Expressions are frequently used in reports. These include expressions to change the appearance of data in a report, change properties of report items, and affect how data is retrieved (filtering and sorting expressions). Many expressions in a report contain functions. You can format data, apply logic, and access report metadata by using these functions: •

String functions



Date and Time functions



Conversion functions



Decision functions



Report functions

This lesson describes some expressions that can be used for common tasks in a report.

String Functions String functions can be used to manipulate string values in a report. You can use several functions to do the following tasks: •

Concatenate fields and constants by using concatenation operators and Visual Basic constants.



Format dates and numbers.



Return substrings.



Change the format of strings.

Combine more than one field by using concatenation operators and Visual Basic constants. The following expression returns two fields, each on a separate line in the same text box:

3 - 30

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

Module 3: Adding Code to a Report Concatenation =Fields!FirstName.Value & vbCrLf & Fields!LastName.Value Format dates and numbers in a string with the Format function. The following expression displays values of the StartDate and EndDate fields in long date format:

Format dates and numbers =Format(Fields!StartDate.Value, "D") & " through " & Format(Fields!EndDate.Value, "D") If the text box contains only a date or number, you should use the Format property of the text box to apply formatting instead of the Format function within the text box. Return Substrings The Right(), Len(), and InStr() functions are useful for returning a substring, for example, trimming DOMAIN\username to just the user name. The following expression returns the part of the string to the right of a backslash (\) character from a report global named User:

Returning a substring =Right(Globals!User.Value, Len(Globals!User.Value) - InStr(Globals!User.Value, "\")) Change the Format of Strings The Regex functions from the .NET Framework System.Text.RegularExpressions are useful for changing the format of existing strings, for example, formatting a telephone number. The following expression uses the Replace function to change the format of a ten-digit telephone number in a field from "nnn-nnn-nnnn" to "(nnn) nnn-nnnn":

Regular expression =System.Text.RegularExpressions.Regex.Replace(Fields!Phone.Value, "(\d{3})[ .]*(\d{3})[ -.]*(\d{4})", "($1) $2-$3")

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

3 - 31

Reporting in Microsoft Dynamics® NAV 2013 Date and Time Functions Date functions are used to analyze and format a date in a report. To format a date, you can either select a predefined format or define a custom format by using several date and time functions, such as the following: •

DatePart



Year



Month



MonthName



Day



Weekday



WeekdayName



Hour



Minute



Second

You can also perform date calculations (by using functions such as DateDiff() and DateAdd()) and converting a string to a date by using CDate(). Now() returns a Date value containing the current date and time according to your system. Examples The Today function provides the current date. This expression is used in a text box to display the date on the report, or in a parameter to filter data based on the current date.

Code Example =Year(Fields!OrderDate.Value) The DateAdd() function is useful for supplying a range of dates based on a single parameter. The following expression provides a date that is six months after the date from a field named StartDate.

Code example =DateAdd(DateInterval.Month, 6, Fields!StartDate.Value) The Year() function displays the year for a particular date. You can use this to group dates together or to display the year as a label for a set of dates. This expression provides the year for a given group of sales order dates. The Month() function and other functions are also used to manipulate dates.

3 - 32

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

Module 3: Adding Code to a Report Code example =Year(Fields!OrderDate.Value)

Conversion Functions You can use Visual Basic functions to convert a field from one data type to a different data type. Conversion functions are used to convert the default data type for a field to the data type needed for calculations or to combine text. Examples are CInt, CStr, CDate, CDec, CDbl, CBool, CLng, CSng, CShort. The following expression converts the constant 500 to type Decimal:

Code Example =CDec(500)

Program Flow Functions You can use decision functions to evaluate a logical or relational condition and return a specific value that is based on the result of the evaluation. The IIF() function returns one of two values, depending on whether the expression is true or not. The following expression uses the IIF() function to return a Boolean value of True if the value of LineTotal exceeds 100. Otherwise it returns False:

Code Example =IIF(IsNothing(Fields!LargePhoto.Value),True,False) You can use multiple IIF() functions (also known as "nested IIFs") to return one of three values, depending on the value of PercentCompleted. The following expression can be positioned in the fill color of a text box to change the background color, depending on the value in the text box.

Code example =IIF(Fields!PctComplete.Value >= 10, "Green", IIF(Fields!PctComplete.Value >= 1, "Blue", "Red")) Values that are greater than or equal to 10 are displayed with a green background, values between one and nine are displayed with a blue background, and a value that is less than one is displayed with a red background. A different way to obtain the same functionality is to use the Switch() function. The Switch() function is useful when you have three or more conditions to test.

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

3 - 33

Reporting in Microsoft Dynamics® NAV 2013 The Switch() function returns the value associated with the first expression in a series that evaluates to true:

Code example =Switch(Fields!PctComplete.Value >= 10, "Green", Fields!PctComplete.Value >= 1, "Blue", Fields!PctComplete.Value = 1, "Yellow", Fields!PctComplete.Value 7,"Red","Blue") Test the Null Value In the following example, you will test the value of the PhoneNumber field. If the field is null (Nothing in Visual Basic), "No Value" is returned; otherwise the phone number value is returned. This expression can be used to control the value of a text box in a report item.

Code example =IIF(Fields!PhoneNumber.Value Is Nothing,"No Value",Fields!PhoneNumber.Value) The following expression can be used to control the Hidden property of an image report item. In the following example, the image specified by the field [LargePhoto] is displayed only if the text value of the field is not null.

Code example =IIF(IsNothing(Fields!LargePhoto.Value),True,False)

3 - 34

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

Module 3: Adding Code to a Report Report Functions Reporting functions are built-in functions for use in expressions to calculate aggregate data in datasets, data regions, and groups. Additionally, reporting functions are used to retrieve other data values, such as the first or last value on a report page. Two of the most important functions are the Sum() and the RowNumber() function. Sum() The Sum() function can total the values in a group or data region. This function can be useful in the header or footer of a group. The following expression displays the sum of data in the Order group or data region:

Code Example =IIF(RowNumber("table1") Mod 2 = 0, "LimeGreen", "Transparent") You can also use the Sum() function for conditional aggregate calculations. For example, if a dataset has a field that is named State with possible values Not Started, Started and Finished, the following expression, when it is positioned in a group header, calculates the aggregate sum for only the value Finished. RowNumber() When the RowNumber() function is used in a text box in a data region, it displays the row number for each instance of the text box in which the expression appears. This function can be useful to number rows in a table. It can also be useful for more complex tasks, such as providing page breaks based on number of rows. The scope that you specify for RowNumber() controls when renumbering begins. The Nothing keyword indicates that the function starts the count at the first row in the outermost data region. To start the count within nested data regions, use the name of the data region. To start the count in a group, use the name of the group.

Code example =RowNumber(Nothing) The following line of code is used to evaluate whether the record in a data region control named table1 is located on an odd or even row number.

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

3 - 35

Reporting in Microsoft Dynamics® NAV 2013 Code example =Iif(RowNumber("table1") Mod 2, "PaleGreen", "White") It can be used to work with alternating background colors.

Appearance of Report Data You can use expressions to manipulate how data appears on a report. For example, you can display the values of two fields in a single text box, display information about the report, or affect how page breaks are inserted in the report. Page Headers and Footers When you design a report, you might want to display the name of the report and page number in the report footer. The following expression provides the name of the report and the time that it is run. It can be positioned in a text box in the report footer or in the body of the report. The time is formatted with the .NET Framework formatting string for short date:

Code Example =Globals.ReportName & ", dated " & Format(Globals.ExecutionTime, "d") The following expression, positioned in a text box in the footer of a report, provides the page number and total pages in the report:

Code example =Globals.PageNumber & " of " & Globals.TotalPages Page Breaks In some reports, you might want to position a page break at the end of a specified number of rows instead of, or in addition to, on groups or report items. To do this, create a group that contains the groups or detail records that you want, add a page break to the group, and then add a group expression to group by a specified number of rows. The following expression uses the Ceiling() function. When it is positioned in the group expression, it assigns a number to each set of 25 rows. When a page break is defined for the group, this expression results in a page break every 25 rows.

3 - 36

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

Module 3: Adding Code to a Report Code example =CInt(Ceiling(RowNumber(Nothing)/25)) For the user to be able to set a value for the number of rows for each page, create a variable RowsPerPage (the number can be added as a variable to the request options page) and then base the group expression on the variable, as is shown in the following expression:

Code example =CInt(Ceiling(RowNumber(Nothing)/Fields!RowsPerPage.Value)) On the Group Header, remember to check the Page Break at End option. A similar technique is also used in the Sales Invoice report, to have multiple copies of the report printed. This is explained in the next lesson.

Properties Expressions are not only used to display data in text boxes. They can also be used to change how properties are applied to report items. You can change style information for a report item, change its visibility, or use dynamic URLs. •

Formatting



Visibility



URLs

Formatting The following expression, when it is used in the Color property of a text box, changes the color of the text, depending on the value of another field, in this case the Profit field:

Code Example =Iif(Fields!Profit.Value < 0, "Red", "Black") To refer to the value of the current field, use the Fields!FieldName syntax, or use the Visual Basic object Variable Me. The following expression, when it is used in the BackgroundColor property of a report item in a data region, alternates the background color of each row between pale green and white:

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

3 - 37

Reporting in Microsoft Dynamics® NAV 2013 Code example =Iif(RowNumber(Nothing) Mod 2, "PaleGreen", "White") If you use an expression for a specified scope (for example the table called Employees in the report), it might be necessary to indicate the dataset for the aggregate function. Therefore, replace the Nothing value by the name of the data region control that corresponds to the scope. Visibility You can show and hide items in a report by using the visibility properties for the report item. In a data region such as a table, when you work with the items for the first time, you can hide detail rows based on the value in an expression. The following expression, when it is used the first time for visibility of detail rows in a group, it shows the detail rows for all sales exceeding 90 percent in the PctQuota field:

Code example =Iif(Fields!PctQuota.Value>.9, False, True) The following expression, when set in the Hidden property of a table, shows the table only if it has more than 12 rows:

Code example =IIF(CountRows()>12,true,false) URLs You can customize URLs (Uniform Resource Locator) by using report data and also conditionally control whether URLs are added as an action for a text box. The following expression, when it is used as an action on a text box, generates a customized URL that specifies the dataset field EmployeeID as a URL parameter.

Code example ="http://adventure-works/MyInfo?ID=" & Fields!EmployeeID.Value The following expression conditionally controls whether to add a URL in a text box. This expression depends on a variable named IncludeURLs that lets a user decide whether to include active URLs in a report. This expression is set as a Hyperlink action (select Properties, and then select the Navigation tab) on a text box.

3 - 38

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

Module 3: Adding Code to a Report Code example =IIF(Parameters!IncludeURLs.Value,"http://adventureworks.com/productcatalog",Nothing)

Custom Code You can use custom code in a report. Custom code is either embedded in a report or stored in a custom assembly which is used in the report. To add code to a report in Visual Studio Report Designer, select Report, and then select Report Properties. On the Code tab, you can create your own custom code (functions and variables) to enrich the report functionalities. It is recommended not to add custom code that executes business logic; instead, use it to add presentation related code. As an example, one of the most common calculations in reports is division. When you divide numeric variables, you have to be careful with NULL and 0 (zero) values because, when you divide a variable by NULL or by 0, it results in a runtime error and or, NaN being returned in the reports. (NaN means Not a Number; it is a value or symbol that is generated as the result of an operation on invalid input terms, especially in floating-point calculations. A typical example is calculating the square root of a negative number. To avoid this, you can create a function that checks the terms and returns the numeric result or, if there is an accidental error, a user-friendly value. The sample division function can resemble this:

Code Example Public Shared Function Divide(Num1 as double, Num2 as double) AS object IF ISNOTHING(Num2) Or Num2 = 0 Then Divide ="n/a" ELSEIF Num1 = 0 THEN Divide = 0 ELSE Divide = Num1 / Num2 END IF End Function

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

3 - 39

Reporting in Microsoft Dynamics® NAV 2013 You can then call this function from an expression such as this: =Code.Divide(1, 0) Instead of calling the Code.Divide function, use an expression with an IIf() statement in each text box where you want to calculate the division. Adding custom code increases the maintainability of your report code. A similar example calls an embedded method called FixSpelling(). This substitutes "Bicycle" for all occurrences of the text "Bike" in the SubCategory field. The example assumes that the following function is embedded on the report's Code tab.

Code example Public Function FixSpelling(ByVal s As String) As String Dim strBuilder As New System.Text.StringBuilder(s) If s.Contains("Bike") Then strBuilder.Replace("Bike", "Bicycle") Return strBuilder.ToString() Else : Return s End If End Function To have the values replaced at run time for each record in the report, set the Value property of the SubCategory field to: =Code.FixSpelling(Fields!SubCategory.Value) The following example calls an embedded code method called ToUSD(). This converts the StandardCost field value to a dollar value.

3 - 40

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

Module 3: Adding Code to a Report Code example =Code.ToUSD(Fields!StandardCost.Value) Custom Variables The following example shows how to define some custom constants and variables.

Code example Public Const MyNote ="Authored by John Doe" Public Const NCopies As Int32 = 2 Public Dim MyVersion As String ="123.456" Public Dim MyDoubleVersion As Double = 123.456 Although custom constants and variables do not appear in the Expression Editor Constants view (which only displays built-in constants), you can add references to them from any expression, as is shown in the following examples. These are treated as Variants.

Code example =Code.MyNote =Code.NCopies =Code.MyVersion =Code.MyDoubleVersion When you create a new report in Microsoft Dynamics NAV 2013, some custom functions are made available in the Code tab of the report properties. The following section will highlight those functions. BlankZero transforms a 0 (zero) value into a blank. Use this function when it is required not to show 0 (zero) values.

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

3 - 41

Reporting in Microsoft Dynamics® NAV 2013 Code example Public Function BlankZero(ByVal Value As Decimal) if Value = 0 then Return "" end if Return Value End Function The BlankPos function will only return negative or zero values. When a positive number (or decimal) is passed into this function, it will not return a value. Use this function if it is required only to show negative or zero values.

Code Example Public Function BlankPos(ByVal Value As Decimal) if Value > 0 then Return "" end if Return Value End Function The BlankZeroAndPos function will only return negative values. When a positive number (or decimal) is passed into this function, it will not return a value. Use this function if it is required only to show negative values.

Code example Public Function BlankZeroAndPos(ByVal Value As Decimal) if Value >= 0 then Return "" end if Return Value End Function

3 - 42

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

Module 3: Adding Code to a Report The BlankNeg function will only return positive or zero values. When a negative number (or decimal) is passed into this function, it will not return a value. Use this function if it is required only to show positive or zero values.

Code example Public Function BlankNeg(ByVal Value As Decimal) if Value < 0 then Return "" end if Return Value End Function The BlankNegAndZero function will only return positive values. When a negative number (or decimal) is passed into this function, it will not return a value. Use this function if it is required only to show positive values.

Code Example Public Function BlankNegAndZero(ByVal Value As Decimal) if Value /Ru nPage?Page=

DynamicsNAV:////CRO NUS%20International% 20Ltd./RunPage?Page= 22

Navigate

Users can send or save quick links to specific pages.

DynamicsNAV://///n avigate?node=

DynamicsNAV://///navi gate?node=Home/Ite ms

RunPage

You can run a specific page.

DynamicsNAV:////ru npage?page=

DynamicsNAV:////runp age?page=42

RunReport

You can run a specific report.

DynamicsNAV:////ru nreport?report=

DynamicsNAV:////runr eport?report=50000

RunQuery

You can run the About This Query page for a specific query.

DynamicsNAV:////ru nquery?query=

DynamicsNAV:////runq uery?query=50000

RunXMLport

You can run a specific XMLport.

DynamicsNAV:////ru nxmlport?xmlport=

DynamicsNAV:////runx mlport?xmlport=99008 500

RunCodeunit

You can run a specific codeunit.

DynamicsNAV:////ru ncodeunit?codeunit =

DynamicsNAV:////runc odeunit?codeunit=500 00

Server name

You can specify servers.

DynamicsNAV://///RunPa ge?Page=

Microsoft.Dynamics.Na v.Client.exe DynamicsNAV://MySer ver///RunPage?Page=2 2

Server port

You can specify an optional server port number in the range 165535. The default port is 7046.

DynamicsNAV:/// //RunPage?Page=< pageid>

DynamicsNAV://MySer ver:1234///RunPage?Pa ge=22

Service instance

You can specify a Service instance. You can find this value in the CustomSettings.config file. If you specify an instance you must also specify a server.

DynamicsNAV://///RunPage?P age=

Microsoft.Dynamics.Na v.Client.exe DynamicsNAV://MySer ver/ //RunPage?Page=22

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

5 - 15

Reporting in Microsoft Dynamics® NAV 2013 If you omit a parameter, such as Server or Service, do not remove the accompanying forward slash. If you remove the accompanying forward slash, it will change the overall structure of the hyperlink. When you type a company name as a parameter, put the hyperlink in quotation marks if there are blank spaces in the name. Best Practice: When you enter a company name on the command line, enclose the quotation marks to make sure that spaces and other special characters are interpreted correctly. For URLs, use percent encoding to escape any characters greater than 127 in the ASCII character set.

Run Hyperlinks In Microsoft Dynamics NAV, you can run report hyperlinks in different ways. You can run the report from the Run window, a Command Prompt, a shortcut or from a browser window. This is useful if, for example, you want to run a specific report for testing, or if you know the ID of a report that is frequently run. The following demonstrations illustrate how to run hyperlinks. Method

To run a hyperlink

Run window

Click Start, and then click Run. Enter the hyperlink in the Run window, and then click OK.

Command prompt window

At the command prompt, type the hyperlink.

Shortcut

Create a shortcut for the Microsoft Dynamics NAV executable on your Desktop. Right-click the shortcut, click Properties, and then enter the hyperlink URL in the Target field of the shortcut. Click OK, and then start Microsoft Dynamics NAV.

Browser window

5 - 16

Use a browser such as Internet Explorer and type the hyperlink URL directly into the address bar. To type hyperlinks into a browser, you must have Microsoft Dynamics NAV installed on your computer.

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

Module 5: Running Reports Method Web Reference for a web service

To run a hyperlink Create a Codeunit that saves the report to PDF, Excel or Word. Publish the Codeunit as a web service. Create an application that includes the web service, for example an ASP.NET website.

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

5 - 17

Reporting in Microsoft Dynamics® NAV 2013 Demonstration: Run a Report from the Run Window Demonstration Steps 1.

Run a report from the Run window. a.

In Microsoft Windows, click Start, and then click Run.

b.

In the Run dialog box, enter the following command:

Code Example “Microsoft.Dynamics.Nav.Client.exe” DynamicsNAV:///runreport?report= Replace with the report ID that you want to use 111. c.

Click OK to run the report.

Demonstration: Run a Report at the Command Prompt Demonstration Steps 1.

Run the report at the command prompt. a.

Click Start, and then click Run.

b.

In the Run window, enter cmd.

c.

In the Command Prompt window, enter the following command:: "C:\Program Files (x86)\Microsoft Dynamics NAV\70\RoleTailored Client\Microsoft.Dynamics.Nav.Client.exe" DynamicsNAV:////runreport?report=111

d.

Press Enter.

Demonstration: Run a Report from a Shortcut To run a report from the Windows Desktop, you can create a shortcut to the report.

Demonstration Steps 1.

5 - 18

Use a shortcut to run a report. a.

On your Windows Desktop, create a shortcut to the Microsoft.Dynamics.Nav.Client.exe.

b.

Right-click the shortcut and select Properties.

c.

In the Target field, add the hyperlink URL. The complete target will resemble this: "C:\Program Files (x86)\Microsoft Dynamics NAV\70\RoleTailored Client\Microsoft.Dynamics.Nav.Client.exe" DynamicsNAV:////runreport?report=111

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

Module 5: Running Reports d.

Click OK to close the Properties window.

e.

Double-click the shortcut to run the report.

Demonstration: Run a Report from a Browser Window Demonstration Steps 1.

Run the report from the browser window. a.

Open Microsoft Internet Explorer.

b.

In the address bar; enter the following URL: dynamicsnav:////runreport?report=111

c.

Press Enter to validate the URL.

The first time that you execute this command, you will receive a confirmation message, as is shown in the Run Report Confirmation figure.

FIGURE 5.8: RUN REPORT CONFIRMATION WINDOW

Demonstration: Add a Report Hyperlink to a Webpage Kevin has asked Tim, the IT manager, to conduct a small feasibility study for building a Customer Portal. A primary goal of this portal is to provide all outgoing sales documents electronically. By doing this, customers can download the documents, and they will also be able to print specific reports.

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

5 - 19

Reporting in Microsoft Dynamics® NAV 2013 Tim checks whether he can start a report from a webpage.

Demonstration Steps 1.

Run a report from a webpage. a.

Click Start, and then open Microsoft Visual Studio 2010.

b.

Select File, New, Web Site.

c.

In the new website window, select the ASP.NET website template.

d.

In the upper-right corner, leave the .NET Framework 4 option.

e.

In the Location field, enter the following path: C:\Users\%USERNAME%\Documents\Visual Studio 2010\WebSites\HyperlinkTest (where %USERNAME% represents your Windows account).

f.

In the Language field, select Visual Basic.

g.

Click the OK button to create a new website.

h.

Click the Source button at the bottom of the window.

i.

Modify the code until it resembles the following line of code:

Code Example Customer Top 10 List

5 - 20

j.

Press F5 to run the website.

k.

If the Debugging Not Enabled dialog box appears, select the Run without debugging option and then click the OK button.

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

Module 5: Running Reports The result will resemble this:

FIGURE 5.9: THE WEBSITE PAGE IN SOURCE VIEW WINDOW

Demonstration: Add a Report Hyperlink to Favorites Now that Tim knows that links to a report can be included on a webpage, he decides do to more testing. Tim wants to know whether links to reports can be added to the Favorites menu in Internet Explorer, and he begins to run the HyperlinkTest site just created.

Demonstration Steps 1.

Add a report to the Favorites menu. a.

Open Microsoft Internet Explorer.

b.

In the address bar; enter the following URL: dynamicsnav:////runreport?report=111

c.

Press Enter to validate the URL.

d.

Right-click the The Customer Top 10 List link.

e.

Select Add to Favorites.

f.

In the Add a Favorite window, enter the following name for the report: Customer - Top 10 List.

g.

Click the New Folder button.

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

5 - 21

Reporting in Microsoft Dynamics® NAV 2013 h.

In the Create a Folder window, enter the following Folder Name: DynamicsNAV Reports.

i.

In the Create In drop-down list, select Favorites.

j.

Click the Create button to create the folder and to return to the Add a Favorite window. Notice that the Create In field points to the newly created folder.

FIGURE 5.10: CUSTOMER TOP 10 LIST PROPERTIES WINDOW k.

Click the Add button to close the Add a Favorite window.

l.

In Internet Explorer, select Favorites, DynamicsNAV Reports.

m. Click the Customer Top 10 List link. The RoleTailored client will be started and the Request Options page for the report is displayed. Tim is satisfied with the results of his tests. He decides to check one more thing. 1.

5 - 22

Verify the URL. a.

In Internet Explorer, select Favorites, DynamicsNAV Reports.

b.

Right-click the Customer Top 10 List link.

c.

Select Properties.

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

Module 5: Running Reports d.

In the Customer Top 10 List Properties window, click the Web Document tab.

FIGURE 5.11: URL PROPERTIES WINDOW Tim knows that the URL field contains the editable link to the report.

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

5 - 23

Reporting in Microsoft Dynamics® NAV 2013

Run a Report from the SharePoint Site You can use the Microsoft Dynamics NAV Portal Framework to display Microsoft Dynamics NAV reports on Microsoft SharePoint sites. There are two ways to display pages and reports: •

Display reports in application pages by using a URL. You can display a report on a SharePoint site by using a URL. To display the report, you can type the URL directly in the address of a web browser or use it to create links to the report from other SharePoint pages. Reports open in an application of the SharePoint site.



Create a page action that runs the report. By using the Microsoft Dynamics NAV development environment, you can create an action to a page, and then set the action to run the report.

Additional Reading: For more information, refer to How to Add Actions to a Page: http://go.microsoft.com/fwlink/?LinkId=267285

Limitations of Reports on a SharePoint Site Limitations exist when you create reports by using the Microsoft Dynamics NAV Portal Framework compared to when you use the RoleTailored client. These limitations include the following: •

Filtering There is a limit on the number of filters a user can set. The user can only specify one filter in addition to the number of filter fields that are set by the ReqFilterFields Property. Filtering is not available on the Request page for reports that are displayed in SharePoint. If you want to filter a report, then add C/AL code to the report’s Request page in the Microsoft Dynamics NAV development environment.



Printing Client-side printing is not supported. You must set up reports to print from Microsoft Dynamics NAV Server. For more information, refer to How to Specify a Printer Selection for Reports and the STARTSESSION Function.

5 - 24

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

Module 5: Running Reports Unlike pages, reports are not supported in Microsoft Dynamics NAV web parts.

Demonstration: Displaying Reports in SharePoint Sites By Using URLs When you use the Microsoft Dynamics NAV Portal Framework for Microsoft SharePoint 2010, instead of opening a SharePoint site and browsing to a report, you can open a report directly by using its URL. When you have the URL of a report, you can use it as a hyperlink to the report. Then, you can include it in other sources, such as email messages or Word documents, or send it to other people. The following link displays report 5 Receivables – Payables for the CRONUS International Ltd. company. The report is displayed in a Microsoft Dynamics NAV web client that is running on port 8080 of a computer that has the name MySharePointServer.

Demonstration Steps 1.

Run the report. a.

Open your browser and type the following address: http://localhost:8080/List.aspx?company=CRONUS%20Internatio nal%20Ltd.&report=5

Report URL Syntax The URL to open a report in the Microsoft Dynamics NAV web client has the following syntax:

Code Example ://[:][/]/report.aspx?report=&[ company=] The following table describes the notation used to indicate address syntax. Notation

Description

Text without brackets

Parameters that you must type as shown.



A placeholder for values that you must supply. Do not include the brackets in the address.

[]

Optional parameters. Do not include the brackets in the address.

|

A set of values from which to select. Use one of the options and do not include this option in the address.

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

5 - 25

Reporting in Microsoft Dynamics® NAV 2013 Remember the following: •

You can put parameters in any order after report.aspx? For example, report.aspx?company=CRONUS%20International%20Ltd.&report=5 yields the same as report.aspx? report=5&company=CRONUS%20International%20Ltd.



Separate parameters after aspx? with &.



Use %20 for any spaces in values and names.

More information about the report URL parameters is available here: http://go.microsoft.com/fwlink/?LinkId=267287

Hyperlinks in a Report In Microsoft Dynamics NAV 2013, you can create reports that provide dynamic data. Microsoft Dynamics NAV 2013 reports can include images, graphics, and interactive sorting. Additionally, you can toggle on data columns and link to other data in the system. This lesson shows how to set up a report to include a link to the Customer Card page. So, when the Customer Card page is run in preview mode, it can search any existing customer directly from the report. By including this functionality, the report no longer serves as a static, printed list. It becomes a dynamic list that can be used for direct drill-down into system data.

Demonstration: Adding a Link in from a Report to a Page When Michael prints the Customer Top 10 List report, he notices that only the customer number and name are included in the list. To find the other customer information, Michael must open the Customer Card. So, Michael asks Mort to include a link to the Customer Card in the report. However, before Mort can include the link in Visual Studio he must add and include a variable in a hidden text box on a section.

Demonstration Steps 1.

5 - 26

Add a Variable and Code to the Report. a.

Open the Microsoft Dynamics NAV 2013 demonstration database.

b.

Open the CRONUS International Ltd. demonstration company.

c.

Select Tools, Object Designer to open the Object Designer.

d.

Select File, Import.

e.

Browse to the report R123456711.fob.

f.

Click OK to start the import.

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

Module 5: Running Reports g.

In the dialog box, choose to open the Import Worksheet window.

h.

In the Action column, verify that the action is set to Create.

i.

Click OK to import the object in the database.

j.

In Object Designer, click Report, and then locate the Customer - Top 10 List report by typing object ID 123456711.

k.

Select the Customer Top 10 List report, and then click the Design button.

l.

In the C/AL Globals of this report there’s a variable CustomerRecRef of DataType RecordRef and in the OnPreDataItem() trigger, the following line of code was added:

Code Example CustomerRecRef.OPEN(18); m. In the OnAfterGetRecord() trigger, the following line of code was added at the bottom of the trigger:

Code Example CustomerRecRef.SETPOSITION(Customer.GETPOSITION); This C/AL code will make sure the recordref variable points to the record of the customer being fetched in the report. 2.

Add the text box and add the line to the report. To add the line to the report, follow these steps. Mort must create a new line in the Report Dataset Designer to add the bookmark of the customer record to the dataset. This line will be used to locate the value of the current customer represented in the dataset in Visual Studio after the layout is opened there. a.

In the Report Dataset Designer window, add a new line at the end of the Integer dataitem.

b.

In the Data Type column select Column.

c.

In the Data Source column enter the following:

Code Example FORMAT(CustomerRecRef.RECORDID,0,10) d.

In the Name column type, CustomerBookmark.

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

5 - 27

Reporting in Microsoft Dynamics® NAV 2013 The value 10 in this expression only formats RECORDID into a text representation that is compatible with the URL handler of reports and pages. e.

Save and compile the report.

After the bookmark is added to the Report Dataset Designer, Mort can open the layout of the report and continue to modify it in Visual Studio. The following steps will add a link to the customer number on the report that opens the customer card for the selected customer. Now the newly created bookmark is part of the dataset in Visual Studio under Data Sources and its value is being referenced in the link that you are adding. f.

In the development environment, with the Customer - Top 10 List report open in Report Designer, click View, and then select Layout.

g.

In Visual Studio, in the Body of the report, locate the text box Customer_No. The value of the text box is [Customer_No].

h.

Right-click the text box and select Properties.

i.

In the Properties window, locate the Action tab.

j.

Select the Go to URL option and enter the following expression in the field:

Code Example ="dynamicsnav:////runpage?page=21&mode=edit&bookmark="+Fields!Custome rBookmark.Value Because the mode parameter is used, the user can edit the customer page. k.

In the Font tab, set the Effects to Underline and set the Color to Blue.

l.

Click OK to close the window.

m. Save the report in Visual Studio and return to the development environment. n.

Save and compile the report.

In the development environment, Mort saves the Customer - Top 10 List report. A message informs him that the .rdlc file for this report has changed and asks if he wants to load the changes. He clicks Yes to save the changes in the database. To compile and save the report, Mort must set the EnableHyperLinks property.

5 - 28

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

Module 5: Running Reports Note: Microsoft Dynamics NAV 2013 cannot verify URLs and protect against malicious sites that can be harmful to your computer. You should set the EnableHyperlinks property to Yes only if you can make sure that hyperlinks on the report target trusted sites. o.

In the Report Dataset Designer, go to the last row and then click the down arrow.

p.

In the Properties window, enter Yes in the EnableHyperLinks property.

q.

Select Tools, and then click Compile to compile the report.

r.

Click Run.

s.

Click Preview to view the report. The report lists the top 10 list of customers.

FIGURE 5.12: CUSTOMER TOP TEN REPORT WINDOW If you are resting on the customer number, you will receive a link to open the specific customer on a separate customer card, and then you can drill down into the customer's data.

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

5 - 29

Reporting in Microsoft Dynamics® NAV 2013 Demonstration: Creating a Link from a Report to a Report This demonstration will show how to set up a report to include a link from the Customer - Top 10 List report to the Customer - Detail Trial Bal. report. When you run the Customer - Top 10 List report in preview mode and show balance data, you can select a value in the Balance (LCY) column or a section of the pie chart to view detailed balance information. By including this functionality, you have a dynamic report, and now you can drill down into data. Before you can add a link from a report to another report, you must enable hyperlinks on the report.

Demonstration Steps 1.

Enable hyperlinks on a report. a.

Open the Microsoft Dynamics NAV 2013 demonstration database.

b.

Select Tools, Object Designer to open the Object Designer.

c.

Select File, Import.

d.

Browse to the report R123456711.fob.

e.

Click OK to start the import.

f.

In the dialog box, choose to open the Import Worksheet window.

g.

In the Action column, verify that the action is set to Create.

h.

Click OK to import the object in the database.

i.

In Object Designer, elect report 123456711, the Customer Top 10 List report, and then select Design. The Report Dataset Designer window opens.

j.

In Report Dataset Designer, select an empty row.

k.

On the View menu, select Properties.

l.

In the Report - Properties window, in the EnableHyperlinks field, set the Value field to Yes if it’s not already set to Yes.

m. On the File menu, select Save, in the Save dialog box, make sure Compile is selected, and then select OK to compile and save the report. n.

5 - 30

Close the Properties and the Report Dataset Designer windows.

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

Module 5: Running Reports 2.

Add a link from the Balance text box on the report to another report. Then, add a link from the Balance field. In the following procedure, you add a link from the balance text box in report 111, the Customer - Top 10 List report to report 104, the Customer Detail Trial Bal. report.

To add a link from the Balance field: a.

On the View menu, select Layout. Visual Studio opens.

b.

In Visual Studio, in the Body section of the report, locate the Customer__Balance__LCY__ text box. The value of the text box is =Fields!Customer__Balance__LCY__.Value. You can confirm this value by selecting the text box and viewing the Value property in the Visual Studio Properties window.

c.

Select the text box, and then select Placeholder Properties.

d.

In the Placeholder Properties window, click the Action tab.

e.

Select the Go to URL check box and enter the following expression in the Select URL text box underneath the Go to URL check box:

="dynamicsnav:////runreport?report=104&filter=Customer.%22No.% 22:"+Fields!Customer__No__.Value

3.

f.

Click OK to close the window.

g.

On the File menu, select Save to save the report in Visual Studio.

Format the Balance text box to indicate that it is a link. After you add the link from the balance text box to report 104 (Customer - Detail Trial Bal.), you might want to change the format of the balance text box to indicate that the data in the text box is a link. a.

In Visual Studio, in the Body section of the report, select the Customer__Balance__LCY__ text box.

b.

On the View menu, select the Properties window.

c.

In the Properties window, in the Color field, select Blue.

d.

Expand Font and set Text Decoration, to Underline.

e.

Save the report in Visual Studio.

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

5 - 31

Reporting in Microsoft Dynamics® NAV 2013 4.

Add a link from the pie chart to report 123456711. a.

In Visual Studio, select the pie chart, and then select Series Properties.

b.

In the Series Properties window, select the Action tab, then select Go to URL and enter the following expression in the Select URL text box underneath the Go to URL check box:

="dynamicsnav:////runreport?report=104 &filter=Customer.%22No.%22:"+Fields!Customer__No__.Value

5.

c.

Select the OK button to close the Series Properties window.

d.

In Visual Studio, on the File menu, select Save Report.rldc to save and then close the report in Visual Studio.

Run the modified report.

In the development environment, you must now save the modified report and compile it before it you can run it.

5 - 32

a.

In the development environment, save the Customer - Top 10 List report.

b.

A message informs you that the .rdlc file for this report has changed and asks whether you want to load the changes. Click Yes to save the changes in the database.

c.

In the Save window, verify that the Compiled check box is selected, and then click OK.

d.

In the development environment, select the Customer Top 10 List report and click Run. The Edit-Customer- Top 10 List page for report 123456711 opens in the RoleTailored client.

e.

Under Options, in the Show drop-down list, click Balance (LCY) and in the Chart Type drop-down list, select Pie chart.

f.

Click Preview to view the report. The report lists the top 10 list of customers. The Balance (LCY) column is formatted as a hyperlink. If you click the pie chart it is also formatted as a hyperlink.

g.

Select a value in a Balance (LCY) column. The Customer - Detail Trial Bal. report for the specified customer opens.

h.

Click a sector in the pie chart that represents a customer. The Customer - Detail Trial Bal. report for the specified customer opens.

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

Module 5: Running Reports

Run a Stand-Alone Report in Visual Studio In Microsoft Dynamics NAV 2013, you can share both the layout and the dataset to debug and, or change the report without having the whole Microsoft Dynamics NAV database. This new functionality is explained in this section. This can be useful when the report does not include a particular dataset or it has rendering issues. Additionally, it can be useful when a developer does not have access to the Microsoft Dynamics NAV installation.

Run an Offline Report Viktor is a Microsoft Certified Partner working for CRONUS International Ltd. He is working on some improvements to the Customer - Top 10 List report. However, during his development phase, he has encountered some problems. Viktor wants to send the report to Microsoft Support to help him troubleshoot the problems. The Microsoft Support engineer wants to be able to view the report and report data offline instead of on a computer that has Microsoft Dynamics NAV installed. Viktor saves the report dataset and the report layout and sends them to the Microsoft Support engineer, who runs the report on his computer by using Visual Studio. Saving the report dataset and layout First, Viktor exports the report dataset to an .xml file. To export the report dataset to an .xml file, follow these steps. 1.

On the computer that has Microsoft Dynamics NAV installed, open the RoleTailored client.

2.

In the RoleTailored client, on the Report tab, select Customer - Top 10 List.

3.

On the request page for the Customer - Top 10 List report, on the Application menu, click Help, and then select About This Page to start the About This Report feature.

4.

Close the About This Page page.

5.

On the Request page for the Customer - Top 10 List report, click Preview to open the Customer - Top 10 List report in Report Viewer.

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

5 - 33

Reporting in Microsoft Dynamics® NAV 2013 6.

On the report preview, on the Application menu, click Help, and then select About This Report to display the report dataset.

7.

On the About This Report page, select Export as XML.

8.

In the Export File dialog box, click Save.

9.

In the Export File dialog box, browse to your desktop, enter Dataset for the file name, set the Save type field to XML (*.xml), and then click Save.

Next, Viktor must save the report layout as an .rdlc file. To copy the report layout .rdlc file, follow these steps.

5 - 34

1.

In the development environment, click Tools, and then click Object Designer.

2.

In Object Designer, click Report, select report 111, Customer - Top 10 List, and then click Design.

3.

On the View menu, click Layout to open the report layout in Visual Studio.

4.

In Visual Studio, in Solution Explorer, select Report.rdlc, and then in the Properties window, note the path where the Report.rdlc file is located.

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

Module 5: Running Reports 5.

Copy the Report.rdlc file from the location in the Properties window to your desktop.

Viktor sends both the Dataset.xml file and the Report.rdlc file to the Microsoft Support engineer who is helping him troubleshoot the report. Running the Report Offline The Microsoft Support engineer has received the Dataset.xml file and the Report.rdlc file from Viktor and now he or she runs the report on his or her computer by using Visual Studio. To run the report by using Visual Studio, follow these steps. 1.

On the second computer, open Visual Studio.

2.

In Visual Studio, in the File menu, click New, and then click Project.

3.

In the New Project window, under Installed Templates, expand Visual C#, select Windows, and then select Windows Forms Application.

4.

In the Name field, enter OfflineReport, and then click the OK button to create the solution.

5.

In Solution Explorer, right-click the OfflineReport project, select Add, and then select Existing Item.

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

5 - 35

Reporting in Microsoft Dynamics® NAV 2013 6.

In the Add Existing Item dialog box, browse to your desktop, set the file type to All Files (*.*), select the Dataset.xml file and the Report.rdlc file, and then click Add.

7.

In Solution Explorer, under OfflineReport, select Dataset.xml. In the Properties window, in the Copy to Output Directory field, select Copy Always from the drop-down list.

8.

In the Toolbox dialog box, under Reporting, drag a new Report Viewer control to Form1.

9.

Select the report viewer control, and then in the Properties window, under Misc, expand Local Report, and then set the ReportEmbeddedResource property, to OfflineReport.Report.rdlc.

Note: If your report includes external images, then in the Properties window of the report viewer control, you must set the EnableExternalImages property to True. Note: If your report includes hyperlinks, then in the Properties window of the report viewer control, you must set the EnableHyperlinks property to True. 10. In Solution Explorer, select the OfflineReport project, click Add, and then click Class. 11. In the Add New Item window, under Installed Templates, select Visual C# Items, and then click Class. 12. In the Name field, enter CreateDataSource.cs, and then select Add. 13. In the CreateDataSource.cs tab, replace the code with the following:

Code Example using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; namespace OfflineReport { public static class CreateDataSource { public static DataTable CreateTable()

5 - 36

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

Module 5: Running Reports { DataSet dataSet = new DataSet(); dataSet.ReadXml("Dataset.xml"); return dataSet.Tables[0]; } } } 14. On the File menu, click Save CreateDataSource.cs. 15. Select the Form1.cs [Design] tab, and then on the View menu, click Code. 16. In the Form1.cs tab, replace the code with the following:

Code Example using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Microsoft.Reporting.WinForms; namespace OfflineReport { public partial class Form1 : Form { public Form1()

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

5 - 37

Reporting in Microsoft Dynamics® NAV 2013 { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet_Result", CreateDataSource.CreateTable())); this.reportViewer1.RefreshReport(); } } } 17. On the Build menu, click Build Solution. The solution builds successfully. 18. On the Debug menu, click Start Debugging to view the report in the report viewer control.

5 - 38

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

Module 5: Running Reports 19. To make a change to the report layout, in Solution Explorer, rightclick Report.rdlc, and then click Open. Note: Now that you have created the OfflineReport solution, to run other reports from Visual Studio, you have to replace the Dataset.xml and Report.rdlc files.

Interesting Links This section provides a list of hyperlinks and resources to use to obtain information about Microsoft Dynamics NAV 2013 and reporting. The Microsoft Dynamics NAV Team Blog This blog site of the Microsoft Dynamics NAV Product team contains technical articles and resources about Microsoft Dynamics NAV. http://go.microsoft.com/fwlink/?LinkId=267288 Microsoft Dynamics Developer Center The Microsoft Developer Network (MSDN) Developer Centers and Resource Centers collect content and resources related to specific products and technologies. They connect you to code samples, community sites, technical articles and documentation, upcoming events, and much more. The Microsoft Dynamics Developer Center provides access to all kinds of development resources for all five Microsoft Dynamics products: (Microsoft Dynamics® AX, Microsoft Dynamics® CRM, Microsoft Dynamics® GP, Microsoft Dynamics® NAV, and Microsoft Dynamics® SL). It offers general information such as product highlights, getting started and learning information. Additionally, it contains links to newsgroups, communities and (team) blogs. http://go.microsoft.com/fwlink/?LinkId=267289 Microsoft SQL Server Development Center The Microsoft SQL Server Development Center contains all kinds of resources and information about development in Microsoft SQL Server®. http://go.microsoft.com/fwlink/?LinkId=267290 In the Microsoft SQL Server Reporting Services (SSRS) section of the SQL Server Developer Center, you can find all kinds of resources related to reporting in SSRS. To go directly to the SSRS section, click the following link: http://go.microsoft.com/fwlink/?LinkId=267291

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

5 - 39

Reporting in Microsoft Dynamics® NAV 2013 Microsoft Visual Studio The following is the home page of the Microsoft Visual Studio product family. http://go.microsoft.com/fwlink/?LinkId=267292 Microsoft Visual Studio Express Editions This site contains resources for the Microsoft Visual Studio Express Editions. The page includes software downloads, samples and resources, information about Frequently Asked Questions (FAQ), system requirements, help resources, installation topics, and forums. http://go.microsoft.com/fwlink/?LinkId=267293 Creating and Consuming a Codeunit Web Service This walkthrough provides an overview of how to create and consume a simple web service that uses Microsoft Dynamics NAV. http://go.microsoft.com/fwlink/?LinkId=267294 Microsoft Dynamics NAV 2013 Launch Portal The Launch Portal references tools, training, and content that you can use to kick start Microsoft Dynamics NAV 2013 readiness. This material supplements the communications and processes that are provided by your local Microsoft country or regional organization. A PartnerSource sign in is required. http://go.microsoft.com/fwlink/?LinkId=267296 Microsoft Dynamics NAV 2013 Developer and IT Pro Help The Microsoft Dynamics NAV 2013 Developer and IT Pro Help provides information about developing for, installing, and managing Microsoft Dynamics NAV 2013. http://go.microsoft.com/fwlink/?linkid=126283 Updates to the developer and IT Pro Help, with both new content and improvements to existing content can be downloaded from the following page: http://go.microsoft.com/fwlink/?linkid=126282 User Experience Guidelines for Microsoft Dynamics NAV 2013 The Microsoft Dynamics NAV 2013 User Experience Guidelines (or “UX Guide” for short) is a tool to help Microsoft Dynamics NAV Independent Software Vendors (ISVs) in building more user-friendly applications. By using the Microsoft UX Guide proactively during your development process, you can save time and avoid design

5 - 40

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

Module 5: Running Reports violations. http://go.microsoft.com/fwlink/?LinkId=267297 Microsoft Dynamics NAV Developer Documentation This page contains links to several technical articles related to development in Microsoft Dynamics NAV. http://go.microsoft.com/fwlink/?LinkId=267300 The Microsoft Dynamics NAV Technical Community This site offers a several tools to help you connect and collaborate with other Microsoft Dynamics NAV users, developers and implementers. http://go.microsoft.com/fwlink/?LinkId=267298 SQL Server 2008 Report Definition Language Specification This document specifies the structure and semantics of the SQL Server 2008 Report Definition Language (RDL), and XML Schema for presenting reports. http://go.microsoft.com/fwlink/?LinkId=267299

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

5 - 41

Reporting in Microsoft Dynamics® NAV 2013

Lab 5.1: Add a Report to the RoleTailored Client Scenario Prakash wants his Resource - Utilization (Chart) Report (report 123456706) to be available from the Role Center menu so that he and other project managers can access it from the RoleTailored client. He asks Mort to make it available in the menu on the Role Center page. Additionally, he wants it to be available from the Resources page in the Departments section (under the Reports and Analysis category).

Objectives In this lab, you will add one of the reports that you built in earlier modules, to the RoleTailored client interface.

Exercise 1: Add a Report to the RoleTailored Client Exercise Scenario Add report 123456706 that is created in Lab 4.2 (Creating a TOP X Report), to the Role Center menu for Prakash and the other project managers. Additionally, create a new MenuSuite object to make the report available under the Reports and Analysis category in the Resources section of the Departments page.

Task 1: Add the Report to the Job Project Manager RC Page. High Level Steps 1.

Add report 123456706 that is created in Lab 4.2, to the Role Center menu for Prakash and the other project managers.

Detailed Steps 1.

5 - 42

Add report 123456706 that is created in Lab 4.2, to the Role Center menu for Prakash and the other project managers. a.

Open the Microsoft Dynamics NAV 2013 demonstration database.

b.

Open the CRONUS International Ltd. demonstration company.

c.

Select Tools, Object Designer to open the Object Designer, in case it’s not already open.

d.

Select File, Import.

e.

Browse to the object P123456700.fob.

f.

Click Yes to start the import.

g.

In the dialog box, choose to open the Import Worksheet window.

h.

In the Action column, verify that the action is set to Create.

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

Module 5: Running Reports i.

Click OK to import the object in the database.

j.

In the Microsoft Dynamics NAV development environment, open Object Designer.

k.

Click the Page button.

l.

Select page 123456700, Job Project Manager RC2.

m. Click Design to open the page in Page Designer. n.

Select an empty line in the designer. In the menu, Select View, and then Page Actions to open Action Designer.

o.

Scroll down to the Action that has Jobs per Item as its Caption.

p.

Click the Separator button to insert a separator.

q.

Scroll down to the ActionContainer that has HomeItems as its Subtype.

r.

Press F3 to insert a new empty line (or select Edit, New).

s.

On the new line, in the Caption field, enter a name for the action: Resource - Utilization (Chart).

t.

In the Type field, select Action.

u.

Click View, and then Properties to open the Properties window for the new action.

v.

In the Value field of the RunObject property, click the dropdown arrow and select report 123456706 in the Object List window.

w. Compile and save the page.

Task 2: Create a New MenuSuite Object High Level Steps 1.

Create the Menusuite object.

Detailed Steps 1.

Create the Menusuite object. a.

In the Microsoft Dynamics NAV development environment, open Object Designer.

b.

Click the MenuSuite button.

c.

Click the New button to open the Design Level window.

d.

In the list box, select Dept - Partner level.

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

5 - 43

Reporting in Microsoft Dynamics® NAV 2013 Task 3: Change the MenuSuite Object to Add the Report to the Departments Section High Level Steps 1.

Add the Report to the Departments Section.

Detailed Steps 1.

Add the Report to the Departments Section. a.

In the Navigation Pane Designer, select the Resource Planning menu.

b.

Expand the Reports group.

c.

Right-click the last report in the Reports group (Resource Price List) and select Create Item.

d.

In the Create Item window, select Report in the Object Type field.

e.

In the Object ID field, type 123456706.

f.

In the Caption field, change the caption to Resource Utilization (Chart).

g.

In the Department Category field, select Reports and Analysis.

h.

Click OK to close the Create Item window.

i.

Compile and save the MenuSuite.

Task 4: Set Permission to Configure the Report High Level Steps 1.

To set permissions to the profile, follow these steps.

Detailed Steps 1.

5 - 44

To set permissions to the profile, follow these steps. a.

Open the Dynamics NAV Client.

b.

In the search box at the right top of the screen type: Profiles.

c.

Select the profile of the PROJECT MANAGER and double click.

d.

The profile card of the PROJECT MANAGER now opens.

e.

Select the button to the right of the Owner ID field.

f.

The Users window opens.

g.

Select the Administrator user and click OK.

h.

Click OK to close the profile card of the PROJECT MANAGER.

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

Module 5: Running Reports Task 5: Create a New Shortcut for the RoleTailored client High Level Steps 1.

Create a New Shortcut for the RoleTailored client.

Detailed Steps 1.

Create a New Shortcut for the RoleTailored client. a.

Right-click the Windows Desktop and select New > Shortcut.

b.

In the Create Shortcut window, click the Browse button.

c.

In the Browse for Folder window, browse to the following path and application: C:\Program Files(x86)\Microsoft Dynamics NAV\70\RoleTailored Client\Microsoft.Dynamics.Nav.Client.exe.

d.

Click the OK button to close the Browse for Folder window.

e.

In the Create Shortcut window, click the Next button.

f.

Enter the following name for the shortcut: Project Manager Profile.

g.

Click the Finish button.

Task 6: Change the New Shortcut for the RoleTailored Client High Level Steps 1.

Modify the New Shortcut for the RoleTailored client.

Detailed Steps 1.

Modify the New Shortcut for the RoleTailored client. a.

Right-click the newly created shortcut.

b.

Select Properties.

c.

Change the Target field to: "C:\Program Files(x86)\Microsoft Dynamics NAV\70\RoleTailored Client\Microsoft.Dynamics.Nav.Client.exe" -configure profile:"Project Manager"

d.

Click the Apply button.

e.

Click the OK button.

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

5 - 45

Reporting in Microsoft Dynamics® NAV 2013 Task 7: Start the RoleTailored Client that has the Project Manager Profile (in Configuration Mode) High Level Steps 1.

Use the shortcut to run the RoleTailored client that has the Project Manager profile.

Detailed Steps 1.

Use the shortcut to run the RoleTailored client that has the Project Manager profile. a.

On the Windows Desktop, double-click the Project Manager Profile icon.

b.

On the Role Center page, click the Report menu.

FIGURE 5.17: ROLE CENTER PAGE WINDOW c.

Click the Departments menu.

d.

Click the Resource Planning section.

Now the Resource - Utilization (Chart) Report is listed under the Reports and Analysis category (as the bottom report in the Reports group).

5 - 46

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

Module 5: Running Reports

Lab 5.2: Call a Report from a Web Service Scenario Susan regularly receives requests and questions from customers about sales invoices and shipments. After Susan records all the details, she sends the information to the representative who is responsible for handling the requests and questions. At the same time, Rebecca receives several requests to resend lost or missing documents to the customers. To better and faster serve the customers, Susan and Rebecca want to quickly search a document (by number), and print a copy of it so that they can add it to the case or send it to the customers. Mort views this as an excellent opportunity to develop a self-serving customer portal.

Objectives In this lab, you will build a codeunit and expose it as a web service. Although this course is not a web development course, it will show how to build a small web application that includes the web service. Although this lab is educational, it does not focus on how to define the appropriate application security. So, it is highly recommended not to implement the lab in a live production environment.

Exercise 1: Run a Report from a Web Service Task 1: Create a New Codeunit. High Level Steps 1.

Create a New Codeunit.

Detailed Steps 1.

Create a New Codeunit. a.

In the Microsoft Dynamics NAV development environment, open Object Designer.

b.

Click the Codeunit button.

c.

Click the New button.

d.

Select File, Save As.

e.

In the ID field, enter 123456701.

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

5 - 47

Reporting in Microsoft Dynamics® NAV 2013 f.

In the Name field, enter Get Sales Document WS.

g.

Check the Compiled field.

h.

Click OK.

Task 2: Add Global Variables to the Codeunit High Level Steps 1.

Add global variables to the codeunit.

Detailed Steps 1.

Add global variables to the codeunit. a.

Select View, C/AL Globals to open the C/AL Globals window.

b.

On the Variables tab, select the first (empty) line.

c.

In the Name field, enter FileName.

d.

In the DataType field, select Text.

e.

In the Length field, enter 250.

f.

Select the next line.

g.

In the Name field, enter SalesInvHdr.

h.

In the DataType field, select Record.

i.

In the Subtype field, click the button and select the Sales Invoice Header table from the Table List window.

j.

Select the next line.

k.

In the Name field, enter SalesCMHdr.

l.

In the DataType field, select Record.

m. In the Subtype field, click the button and select the Sales Cr.Memo Header table from the Table List window.

5 - 48

n.

Select the next line.

o.

In the Name field, enter SalesShptHdr.

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

Module 5: Running Reports p.

In the DataType field, select Record.

q.

In the Subtype field, click the button and select the Sales Shipment Header table from the Table List window.

FIGURE 5.18: THE C/AL GLOBALS WINDOW r.

Click File, Save to save and compile the codeunit.

Task 3: Add the CheckInvoiceNo function to the Codeunit High Level Steps 1.

Add the CheckInvoiceNo function to the codeunit.

Detailed Steps 1.

Add the CheckInvoiceNo function to the codeunit. a.

In the C/AL Globals window, click the Functions tab.

b.

On the first empty line, enter CheckDocNo.

c.

Place the pointer on the line that contains the CheckDocNo function and then click the Locals button to open the C/AL Locals window.

d.

On the Parameters tab, select the first empty line.

e.

In the Name field, enter DocType.

f.

In the DataType field, select Integer.

g.

Select the next line.

h.

In the Name field, enter DocNo.

i.

In the DataType field, select Code.

j.

In the Length field, enter 20.

k.

Click the Return Value tab.

l.

In the Return Type field, select Integer.

m. Close the C/AL Locals window.

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

5 - 49

Reporting in Microsoft Dynamics® NAV 2013 Task 4: Add Code to the CheckDocNo Function High Level Steps 1.

Add code to the CheckDocNo function.

Detailed Steps 1.

Add code to the CheckDocNo function. a.

In the C/AL Editor, enter the following code in the CheckDocNo() function trigger:

Code Example CASE DocType OF 110: BEGIN IF SalesShptHdr.GET(DocNo) THEN BEGIN EXIT(1) END ELSE EXIT(0); END; 112: BEGIN IF SalesInvHdr.GET(DocNo) THEN BEGIN EXIT(1) END ELSE EXIT(0); END; 114: BEGIN IF SalesCMHdr.GET(DocNo) THEN BEGIN

5 - 50

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

Module 5: Running Reports EXIT(1) END ELSE EXIT(0); END; END; b.

Click File and then click Save to compile the codeunit. The function trigger will resemble this:

FIGURE 5.19: SALES INVOICE REPORT

Task 5: Add the GenerateReport Function to the Codeunit High Level Steps 1.

Add the GenerateReport function to the codeunit.

Detailed Steps 1.

Add the GenerateReport function to the codeunit. a.

In the C/AL Globals window, click the Functions tab.

b.

On the first empty line, enter GenerateReport.

c.

Place the pointer on the line that contains the GenerateReport function and then click the Locals button to open the C/AL Locals window.

d.

On the Parameters tab, select the first empty line.

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

5 - 51

Reporting in Microsoft Dynamics® NAV 2013 e.

In the Name field, enter DocType.

f.

In the DataType field, select Integer.

g.

Select the next line.

h.

In the Name field, enter DocNo.

i.

In the DataType field, select Code.

j.

In the Length field, enter 20.

k.

Click the Return Value tab.

l.

In the Return Type field, select Text.

m. In the Length field, enter 250. n.

Close the C/AL Locals window.

o.

Close the C/AL Globals window to return to the C/AL Editor.

Task 6: Add Code to the GenerateReport Function High Level Steps 1.

Add code to the GenerateReport function.

2.

Create the temp folder.

Detailed Steps 1.

Add code to the GenerateReport function. a.

In the C/AL Editor, enter the following code in the GenerateReport() function trigger.

Code Example // Determine the PDF File Name FileName := 'C:\temp\'; FileName := FileName + FORMAT(CREATEGUID); FileName := DELCHR(FileName, '=', '{-}'); FileName := FileName + '.pdf'; // Print the Document IF DocType = 110 THEN BEGIN SalesShptHdr.SETRANGE("No.", DocNo); IF SalesShptHdr.FINDFIRST THEN REPORT.SAVEASPDF(208, FileName, SalesShptHdr); END;

5 - 52

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

Module 5: Running Reports IF DocType = 112 THEN BEGIN SalesInvHdr.SETRANGE("No.", DocNo); IF SalesInvHdr.FINDFIRST THEN REPORT.SAVEASPDF(206, FileName, SalesInvHdr); END; IF DocType = 114 THEN BEGIN SalesCMHdr.SETRANGE("No.", DocNo); IF SalesCMHdr.FINDFIRST THEN REPORT.SAVEASPDF(207, FileName, SalesCMHdr); END; EXIT(FileName); b.

Click File and then click Save to compile the codeunit. The function trigger will resemble this:

FIGURE 5.20: CODE EXAMPLE WINDOW c.

Close the C/AL Editor.

d.

Close Object Designer.

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

5 - 53

Reporting in Microsoft Dynamics® NAV 2013 2.

Create the temp folder. a.

On the C:\ drive create a new folder called temp.

Task 7: Expose the Codeunit as a Web Service High Level Steps 1.

Expose the Codeunit as a web service.

Detailed Steps 1.

5 - 54

Expose the Codeunit as a web service. a.

In the RoleTailored client, browse to: Departments > Administration > IT Administration > General.

b.

Select WebServices in the Lists category.

c.

In the Web Services window, click the New button.

d.

In the Object Type field, select Codeunit.

e.

In the Object ID field, enter 123456701.

f.

In the Service Name field, enter Get_Sls_Doc.

g.

Put a check mark in the Published field, and then click the OK button.

h.

The codeunit is now exposed as a web service.

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

Module 5: Running Reports Task 8: Test the Availability of the New Web Service High Level Steps 1.

Test the availability of the new web service.

Detailed Steps 1.

Test the availability of the new web service. a.

Open Internet Explorer.

b.

In the browser bar, enter the following URL: http://localhost:7047/DynamicsNAV70/WS/services

The newly published web service appears in the list that uses the service name that is specified in the Web Services window.

Task 9: Create a New Website High Level Steps 1.

Create a new website.

Detailed Steps 1.

Create a new website. a.

Select Start > All Programs > Microsoft Visual Studio 2010 > Microsoft Visual Studio 2010.

b.

Select File, New, Web Site.

c.

In the New Web Site window, select the ASP.NET Web Site template.

d.

In the Location field, enter the following path: C:\Users\Administrator\Documents\Visual Studio 2010\WebSites\Lab52

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

5 - 55

Reporting in Microsoft Dynamics® NAV 2013 e.

In the Language field, select Visual Basic.

f.

Click the OK button to create the new website.

g.

Remove the code in the last asp:content tag.

The result should resemble this:

The ASP Editor window in the middle displays a tab for the default page of the website. This is called default.aspx. Notice the Design, Split and Source buttons at the bottom of the ASP Editor window. a.

Click the Design button to switch to the design view.

Task 10: Add Controls to the Website High Level Steps 1.

Add controls to the website.

Detailed Steps 1.

5 - 56

Add controls to the website. a.

In the Toolbox dialog box, select the RadioButtonList control.

b.

Drag it inside the element on the default.aspx page. The control remains selected on the design surface.

c.

Press the right arrow to place the pointer next to the control.

d.

Press Enter.

e.

In the Toolbox window, select the text box control.

f.

Drag it inside the element, under the RadioButtonList.

g.

With the Text box control selected, press the spacebar two times to insert two blank spaces after the control.

h.

In the Toolbox window, select the Label control.

i.

Drag it inside the element, right next to the text box.

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

Module 5: Running Reports j.

With the Label control selected, press the right arrow key to place the cursor next to the control.

k.

Press Enter.

l.

In the Toolbox window, select the Button control.

m. Drag it inside the element, under the text box control. The result will resemble this.

Task 11: Design the Controls on the Website High Level Steps 1.

Design the controls on the website.

Detailed Steps 1.

Design the controls on the website. a.

Select the text box control.

b.

In the Properties window, set the (ID) property to txtDocNo.

c.

Expand the Font property collection.

d.

Set the Name property to Verdana.

e.

Set the Size property to Small.

f.

Select the Label control.

g.

In the Properties window, set the (ID) property to lblErrorMsg.

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

5 - 57

Reporting in Microsoft Dynamics® NAV 2013 h.

Set the ForeColor property to Red.

i.

Set the Text property to Error Message.

j.

Set the Visible property to False.

k.

Expand the Font property collection.

l.

Set the Bold property to True.

m. Set the Name property to Verdana. n.

Set the Size property to Small.

o.

Select the Button control.

p.

In the Properties window, set the (ID) property to cmdSearch.

q.

Set the Text property to Search.

r.

Expand the Font property collection.

s.

Set the Name property to Verdana.

t.

Set the Size property to Small.

u.

Select the RadioButtonList control.

v.

In the Properties window, set the (ID) property to rblDocType.

w. Expand the Font property collection. x.

Set the Name property to Verdana.

y.

Set the Size property to Small.

z.

Click the angle bracket (>) button on the upper-right corner of the RadioButtonList control.

aa. In the RadioButtonList Tasks pane, select Edit Items. bb. In the ListItem Collection Editor window, click the Add button. cc. In the ListItem properties window, set the Text property to Posted Invoice. dd. Change the Value property to 112. ee. Set the Selected property to True. ff. Click the Add button. (The newly added item will appear in the Members list.) gg. In the ListItem properties window, set the Text property to Posted Credit Memo. hh. Change the Value property to 114. ii.

Click the Add button. (The newly added item will appear in the Members list.)

jj.

In the ListItem properties window, set the Text property to Posted Shipment.

kk. Change the Value property to 110. ll.

Click the OK button to close the ListItem Collection Editor window.

mm.

5 - 58

Click File and then click Save to save the file.

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

Module 5: Running Reports The result will resemble this:

Task 12: Add the Web Service Reference High Level Steps 1.

Add the web service reference.

Detailed Steps 1.

Add the web service reference.

Because including a web service is not part of the scope for this training, it is recommended to check the online help for Microsoft Dynamics NAV 2013 or the MSDN website at http://go.microsoft.com/fwlink/?LinkId=267301. a.

In the Solution Explorer window, right-click the Lab52 project and select the Add Web Reference button to open the Add Web Reference window. In case the Add Web Reference button is not available then in the Solution Explorer window, right-click the Lab52 project and select the Add Service Reference ,click the Advanced button, in the Service Reference Setting window click the Add Web Reference button to open the Add Web Reference window.

b.

In the URL field, enter http://localhost:7047/DynamicsNAV70/WS/services.

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

5 - 59

Reporting in Microsoft Dynamics® NAV 2013 c.

Click the Go button.

d.

In the left list box, Discovery Page, click the View Service link for the Get_Sls_Doc service.

e.

Click the Add Reference button to add a reference to the web service.

Task 13: Add Code to Include the Web Service High Level Steps 1.

Add code to include the webservice.

Detailed Steps 1.

Add code to include the webservice. a.

Click the Default.aspx tab.

b.

Double-click the Search button in Design view.

c.

On the Default.aspx.vb tab, enter the following line of code in the cmdSearch_Click procedure.

Code Example Dim service As localhost.Get_Sls_Doc = New localhost.Get_Sls_Doc Dim pdfFileName As String Dim DocCheck As Integer service.UseDefaultCredentials = True

5 - 60

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

Module 5: Running Reports service.Url = "http://localhost:7047/DynamicsNAV70/WS/CRONUS%20International%20Ltd./Co deunit/Get_Sls_Doc" DocCheck = service.CheckDocNo(rblDocType.SelectedValue, txtDocNo.Text) If DocCheck = 0 Then lblErrorMsg.Text = rblDocType.SelectedItem.Text & " " & txtDocNo.Text & " was not found." lblErrorMsg.Visible = True txtDocNo.Text = "" Else lblErrorMsg.Visible = False service.UseDefaultCredentials = True service.Url = "http://localhost:7047/DynamicsNAV70/WS/CRONUS%20International%20Ltd./Co deunit/Get_Sls_Doc" Response.ContentType = "application/pdf" pdfFileName = service.GenerateReport(rblDocType.SelectedValue, txtDocNo.Text) Response.TransmitFile(pdfFileName) End If

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

5 - 61

Reporting in Microsoft Dynamics® NAV 2013 The result will resemble this:

d.

Click File, Save All to save the modified files.

Task 14: Run the Web Application High Level Steps 1.

Run the web application.

Detailed Steps 1.

5 - 62

Run the web application. a.

On the Default.aspx page, press F5.

b.

If the Debugging Not Enabled dialog box is displayed, select the Start without debugging option and click the OK button.

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

Module 5: Running Reports The result will resemble this:

Task 15: Test the Web Application High Level Steps 1.

Test the web application.

Detailed Steps 1.

Test the web application. To test the application, use the following scenario. a.

Select the Posted Shipment option.

b.

In the text box, enter 103007.

c.

Click the Search button.

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

5 - 63

Reporting in Microsoft Dynamics® NAV 2013

5 - 64

d.

Select the Posted Invoice option.

e.

In the text box, enter 103007.

f.

Click the Search button.

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

Module 5: Running Reports

Module Review Module Review and Takeaways This module described how to run a report from the Role Tailored Client from a Page, Role Center and Departments section. It also explained how to create hyperlinks from and to reports and pages and how to run a report from the SharePoint Site. There’s a description on how to run a report standalone in Visual Studio for debugging purposes. The labs in this module enforced knowledge on how to add a report to the application and how to consume a report as a web service.

Test Your Knowledge Test your knowledge with the following questions. 1.

Which functionalities are available from the ReportViewer Control Toolbar? ( ) Find ( ) Save Page Setup ( ) Browse ( ) Sort

2.

Which property determines whether a menu or menu group will be included as a page in the Departments page of the RoleTailored Client? ( ) Department Menu ( ) Department Page ( ) Department Level ( ) Department Category

3.

Which department categories are available in the Create Item window? ( ) Lists, Tasks, Reports and Analysis, Documents, Departments, Home ( ) Lists, Tasks, Reports and Analysis, Documents, History, Setup ( ) Lists, Tasks, Reports and Analysis, Documents, History, Administration ( ) Lists, Tasks, Reports and Analysis, Documents, Departments, Periodic Activities

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

5 - 65

Reporting in Microsoft Dynamics® NAV 2013 4.

What is the RoleTailored client's equivalent for the navigation pane? ( ) The Role Center Pages ( ) The Activities Pages ( ) The Action Pane ( ) The Departments Page

5.

What is true about MenuSuites for the RoleTailored client? ( ) They are stored as separate MenuSuite objects. ( ) They are stored inside the MenuSuite object for the Classic client. ( ) They compromise the Departments page. ( ) They compromise the navigation pane.

5 - 66

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

Module 5: Running Reports

Test Your Knowledge Solutions Module Review and Takeaways 1.

Which functionalities are available from the ReportViewer Control Toolbar? (√) Find ( ) Save Page Setup ( ) Browse ( ) Sort

2.

Which property determines whether a menu or menu group will be included as a page in the Departments page of the RoleTailored Client? ( ) Department Menu (√) Department Page ( ) Department Level ( ) Department Category

3.

Which department categories are available in the Create Item window? ( ) Lists, Tasks, Reports and Analysis, Documents, Departments, Home ( ) Lists, Tasks, Reports and Analysis, Documents, History, Setup (√) Lists, Tasks, Reports and Analysis, Documents, History, Administration ( ) Lists, Tasks, Reports and Analysis, Documents, Departments, Periodic Activities

4.

What is the RoleTailored client's equivalent for the navigation pane? ( ) The Role Center Pages ( ) The Activities Pages ( ) The Action Pane (√) The Departments Page

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

5 - 67

Reporting in Microsoft Dynamics® NAV 2013 5.

What is true about MenuSuites for the RoleTailored client? (√) They are stored as separate MenuSuite objects. ( ) They are stored inside the MenuSuite object for the Classic client. ( ) They compromise the Departments page. ( ) They compromise the navigation pane.

5 - 68

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

MODULE 6: UPGRADE REPORTS Module Overview In Microsoft Dynamics® NAV 2013, you can create reports or you can import reports from earlier versions of Microsoft Dynamics NAV. Typically, reports from an earlier version are migrated to Microsoft Dynamics NAV 2013. To avoid the loss of work, this module explains how to migrate reports to Microsoft Dynamics NAV 2013.

Objectives The objectives are: •

Explain the report upgrade workflow for different report types.



Implement report dataset optimization.



Describe the upgrade process and flow of reports to the RoleTailored client.



Explain how to use the dataset for the report dataset designer.



Describe how to upgrade classic reports.



Apply dataset optimization techniques in reports.



Apply report design UX guidelines.



Optimize performance.



Build the request page.



Import and upgrade a report that has only a Classic report layout to a Microsoft Dynamics NAV 2013 report that has an RDLC layout.



Modify the RDLC layout.

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

6-1

Reporting in Microsoft Dynamics® NAV 2013

How to Upgrade a Report to Microsoft Dynamics NAV 2013 This lesson explains the upgrade process for reports from an earlier version of Microsoft Dynamics NAV to Microsoft Dynamics NAV 2013.

Upgrading a Report Upgrading reports is an automated process that extracts dataset information and deletes unnecessary classic report components from the report object. In Microsoft Dynamics NAV 2009, a report object can contain the following combinations of components: •

Classic report layout (sections) and (optional) request form.



Client report definition (RDLC) layout and (optional) request page.



A hybrid report that contains both the classic report layout (sections) and the (optional) request form and an RDLC report layout and (optional) request page.



A ProcessingOnly report without a layout.

In Microsoft Dynamics NAV 2013, a report object can contain only an RDLC layout and request page. If you import a report from Microsoft Dynamics NAV 2009 that has both the classic report layout and the RDLC report layout, then you must upgrade that report. In Microsoft Dynamics NAV 2013, you can compile. However, you cannot run or design a report that has a classic report layout. When you upgrade a report, the classic report layout and the Request form are deleted. Then, the field information from the report sections is converted to a dataset definition that is valid for Microsoft Dynamics NAV 2013 reports. Dynamics NAV 2013 uses RDLC 2008 and this implies an adjustment and modification to convert and upgrade of the RDLC XML source file. You can have reports that do not have RDLC layouts. For example, you could have deleted the RDLC layout from a report so that you could view the Classic layout only. You can also have a report from a version that is from an earlier version of Dynamics NAV. If this is the case, your report does not contain an RDLC layout or a request page. If you import a report that has only a Classic report layout and request form, then when you upgrade the report, an RDLC report layout is created automatically. You can create a request page for the report or you can use the form transformation tool to transform a request form to a request page.

6-2

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

Module 6: Upgrade Reports After you upgrade a report, it is converted from an RDLC 2005 format to an RDLC 2008 format. To convert a report to RDLC 2008 format, open the report in either Visual Studio 2010 Report Designer or from the RoleTailored client that uses Report Viewer 2010.

Upgrade the Path for a Hybrid Report The steps that are required to upgrade a hybrid report are outlined in the following flowchart.

FIGURE 6.1: UPGRADE HYBRID REPORT WORKFLOW SCREENSHOT

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

6-3

Reporting in Microsoft Dynamics® NAV 2013 Best Practice: For the Upgrade Report to work, you must first compile the report.

Upgrade the Path for a Processing Only Report A processing only report is a report without a layout. The report does not produce any printed output. This type of report processes data. The steps that are required to upgrade a processing only report are outlined in the following flowchart.

FIGURE 6.2: UPGRADE PROCESSING ONLY REPORT WORKFLOW SCREENSHOT

6-4

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

Module 6: Upgrade Reports Upgrade the Path for a Classic Report A Classic report is a report that contains a Classic layout but no RDLC layout. The steps that are required to upgrade a Classic report are outlined in the following flowchart.

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

6-5

Reporting in Microsoft Dynamics® NAV 2013 The Upgrade Process Before you upgrade reports, it is recommended that you create a backup of the reports. You cannot undo the upgrade after it is finished. To back up reports, use one of the following methods: •

Export the reports to a file. (FOB, TXT or XML)



Create a backup of the database.

Note: Verify that you have Visual Studio 2010 installed. This includes the Visual Web Developer feature. You can use any of the following editions of Visual Studio 2010: •

Premium



Ultimate

To upgrade a report, follow these steps. 1.

In the development environment, on the Tools menu, click Object Designer.

2.

Import the report that you want to upgrade into Microsoft Dynamics NAV 2013.

3.

In Object Designer, click Report, and then select the report that you want to upgrade.

4.

To compile the report, click Tools, Compile.

5.

On the Tools menu, click Upgrade Report.

6.

Click the Yes button to confirm that you want to upgrade the reports.

FIGURE 6.4: CONFIRM UPGRADE OF REPORT SCREEN SHOT

6-6

7.

The Classic report layout and request form for each report is deleted during the upgrade. (The Transformation Tool could be used to transform it to a Request Page.)

8.

Select the report that you upgraded, and then click Design.

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

Module 6: Upgrade Reports 9.

On the View menu, click Layout to open Visual Studio Report Designer.

10. Click the OK button to convert the report to RDLC 2008 format. 11. On the File menu, click Save Report.rdlc. 12. In the Microsoft Dynamics NAV development environment, select an empty line in Report Dataset Designer. A dialog box appears with the following message: “The layout of report id: '' is changed by another application. Filename of the changed RDLC: Do you want to load the changes?” 13. Click Yes to load the changes. 14. In the development environment, on the File menu, click Save. 15. In the Save dialog box, click Compile, and then click the OK button.

Optimize the Dataset for the New Report Dataset Designer This lesson explains how to prepare to upgrade a report to Microsoft Dynamics NAV 2013.

Describe How the Dataset is Generated Before you manually update the new RDLC report layout, you should analyze and understand the report. Sometimes you can achieve the same result by using different functionality in the RDLC layout than in the Classic report layout. By understanding the report and the features that are available in Visual Studio Report Designer, you can determine the manual modifications that you must make to the new RDLC report layout. For example, the filtering can be managed in the development environment or in the Visual Studio Report Designer. Additionally, you should understand how the dataset that contains the data that is displayed in the report is generated. For a Classic report layout, the data for each data item is retrieved from the data item and it is formatted in the report sequentially. For example, if you run an Order Confirmation report for multiple sales orders and the data for the first order is retrieved and formatted for the Classic report layout, then the data for the second order is retrieved and formatted, and so on.

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

6-7

Reporting in Microsoft Dynamics® NAV 2013 For an RDLC report layout, all data for the report is retrieved from the data item into one dataset. Then the data is included in the RDLC layout. For example, if you run an Order Confirmation report for multiple orders, then the data from all orders is merged into one dataset. The layout specifies that the data is grouped on pages according to the sales order number. More information about the generation of the dataset is available in the “Creating Reports” module.

Optimize the Dataset You must understand the dataset to understand the report and know how to debug it. Report performance is an important concept of report design, especially when you upgrade a report. Optimizing the dataset of a report usually means minimizing the dataset. The fewer rows that are located in the dataset at run time, the quicker the report will execute and fewer memory resources are consumed. When a report dataset grows, the application will consume increased memory and then when memory is no longer available, the report execution fails. To avoid this scenario, you can optimize the dataset by following these guidelines. Captions and Labels In reports that are upgraded from earlier versions of Microsoft Dynamics NAV 2013, the field captions are columns of the dataset. To have the caption of a field, title for a chart, or a title for the report, translated into the user’s language at run time, the field is added as a column in the dataset. In the Microsoft Dynamics NAV 2013 Report Dataset Designer, you can use labels instead. You can add labels that are related to another data item, such as the caption for a table field, or labels that are not related to another data item, such as the title of the report. Labels are passed as parameters to the report. The Label Report Parameter figure shows an example.

6-8

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

Module 6: Upgrade Reports

FIGURE 6.5: LABEL REPORT PARAMETER Note: In Visual Studio Report Designer, if you want to use the Caption or CaptionML values of a field as a label on a report layout, then you must include the caption in the dataset. You design the dataset by using Report Dataset Designer. When you add table fields to the dataset with Report Dataset Designer, you can set the IncludeCaption property to Yes to specify that the caption for the field is also added to the dataset. If you do not include the caption in the dataset, then in a multilanguage application, you cannot change the language of the labels in the report. You can set the IncludeCaption property in the Properties window of a data item or in the IncludeCaption column of Report Dataset Designer for a data item or a column. If you set the IncludeCaption column of a data item, then the IncludeCaption property is set to Yes for every child column of the data item. The following is a summary of captions and labels: •

If there is a caption in the source expression, then consider using IncludeCaption instead.



If there is a text constant in the source expression, consider using a Label.



There is a significant reduction in memory consumption when values are passed as report parameters instead of fields on each row.

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

6-9

Reporting in Microsoft Dynamics® NAV 2013 Remove unused columns from the dataset A column in the report dataset designer will become a column in the result set that is generated at run time. If the field is not used or not required to be available in the resultset, it should be removed from the report dataset designer. This reduces memory consumption and provides improved report execution. Avoid the usage of binary large object (BLOB) fields in the dataset A BLOB field can potentially contain 2gb of data. Adding it to the report dataset can potentially increase the size of the dataset significantly. When a BLOB field, for example the company logo, is required in the dataset it is recommended to use a separate integer data item to hold the BLOB field(s). You can filter the integer dataitem in its DataItemTableView property by using this filter: WHERE(Number=CONST(1)) Avoid unnecessary rows in the result set If a data item is in the Report Dataset Designer for calculations only, and its fields are not required for the dataset, consider using the DataItemTable view property of the data item to filter the data item. Apply the correct filters in the dataset Filters can be applied in the RDLC layout of a report. All report data regions in Visual Studio Report Designer can be used for filtering at run time. However, if the same result can be achieved by applying filters in the Report Dataset Designer, by using properties or C/AL code, it will produce a smaller dataset and improve report execution performance. Filter, sort, and aggregation is more efficient on the data source than during report processing. A good example of this technique can be found here: http://code.msdn.microsoft.com/windowsdesktop/How-to-boost-performanceffb6c384 “How to boost performance on Dynamics NAV RTC reports: Report 1001, Inventory Valuation”

The Windows Page File The following demonstration will show how to set the size of the page file.

Demonstration: Change the Size of the Windows Page File When a report is executed, the dataset is sent from the Microsoft Dynamics NAV server into the memory on the server. If the dataset exceeds the memory Windows makes available, then Windows will stop allocating additional memory and the client might stop responding. If you cannot reduce the dataset, then the only alternative is to increase available memory on the server.

6 - 10

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

Module 6: Upgrade Reports You can do this by physically adding more memory or by increasing the page file in Windows. Keep in mind that the Client is still a 32-bit application. Best Practice: Windows can handle the size of the page file for general Windows performance. So interfering with this can cause problems for any other tasks that are running on that server. So if you do decide to increase the page file, then it recommended that you do this on a dedicated server that is used to print only large reports.

Demonstration Steps 1.

Change the page file. a.

Click Control Panel > System and Security > System > Advanced System Settings > Advanced.

b.

Click “Settings…” in the “Performance” section.

c.

Select the Advanced tab.

d.

Click Change on the Virtual Memory section.

e.

The Virtual Memory window appears.

FIGURE 6.6: CHANGE PAGE FILE

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

6 - 11

Reporting in Microsoft Dynamics® NAV 2013 f.

Deselect the option: Automatically manage paging file size for all drives.

g.

Select custom size.

h.

Enter an initial size and a maximum size in the corresponding fields.

i.

Restart the server.

Note: Finding the correct values for the initial size and maximum size could require several tries. Changing the page file settings does not affect the performance of reports. However, by doing this, the client can receive more data before it runs out of memory.

Optimize the Layout for RDLC 2008 This lesson explains how to redesign the layout to prepare for an upgrade to Microsoft Dynamics NAV 2013.

Report Design Guidelines In Microsoft Dynamics NAV 2013, for reports, the standard application uses new Report Design Guidelines. This provides consistency to reports. Now when you design a report, other developers will be familiar with the appearance of the report, and they will no longer have to invent a new appearance for each report. Additionally, the Report Design Guidelines will help you save time when you design reports. More information about the Report Design Guidelines is available in the “Creating Reports” module of this course.

Report Performance Optimization Tips Conditional visibility on a big dataset For report items with conditional visibility, the report processor must apply grouping, sorting, and filtering expressions even if only top level data is visible. Although on-demand processing optimizes data evaluation by processing only visible data, all data is part of the report. If the user only wants to have detail data visible sometimes, a drill down report is a better choice.

6 - 12

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

Module 6: Upgrade Reports Best Practices when Displaying Data on a Chart Consider how much data is needed for a chart or gauge. Typically, having more pixels on a monitor will decrease performance and the visual display of graphics. It is recommended not to have more than seven or eight sections in a pie chart. Some charts, such as, scatter graphs, benefit from many data points, whereas other charts, such as pie charts, are more effective with fewer data points. Therefore, carefully select a chart type based on the values in your dataset and how you want this information to be shown. Some ways to combine data on a chart, include the following: •

When you use a pie chart, merge small sections into one section called "Other." This reduces the number of sections on your pie chart.



When there are several data points, do not use data point labels. Data point labels are most effective when there are only a few points on the chart.



Filter unwanted or irrelevant data. This helps highlight the key data that you are trying to show on the chart.



If you want to add a bar graph to show ratio data in a table or matrix template, consider using a linear gauge instead. Gauges are better suited in displaying a single value inside a cell.

Expressions in the Page Header or Footer Force All Pages To Be Processed When you include a reference to the built-in field [&TotalPages], the report processor must paginate the whole report before it can render the first page. If no reference to [&TotalPages] exists, the first page can be rendered and returned to the user immediately, without processing the rest of the report. Additionally, the report processor assumes that any complex expression in the page header or footer might contain a direct or indirect reference to [&TotalPages]. To avoid having the report processor paginate a lengthy report, do not include a reference to [&TotalPages] or any complex expressions in the page header and page footer. Complex Tablix Data Region Grouping and Aggregate Functions Many levels of nested and adjacent groups in a Tablix data region can affect report processing performance. Consider the level of grouping, the number of group instances, and the aggregate functions that require being evaluated after group, filter, and sort expressions are applied. For example, Previous is an 'expensive' aggregate function because its value depends on the sorted elements of a data region; Sum is not order-dependent and requires fewer resources. Other post-sort aggregates include First and Last.

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

6 - 13

Reporting in Microsoft Dynamics® NAV 2013 Reducing the data in the report might be sufficient to provide acceptable performance without changing any aggregate function calls. Report is Not Optimized for the Chosen Rendering Format Some features are not supported in all renderers. If the primary format for viewing a report is a specific file format, you might have to modify the report design for a better viewing experience for the user. For example, each page break defines a new sheet in Excel. Each sheet can handle no more than 65000 rows. Consider these limits when you set the page breaks in a report. For exporting to Excel, do not merge cells in a Tablix data region. In free form reports, align report items vertically. Merged cells and unaligned report items interfere with Excel functionality in the exported report. Design Tips for Better Report Processing For better report performance, use the following information to help increase the time that is required to process your report:

6 - 14



For reports that have many instances of text boxes, set CanGrow and CanShrink on text boxes to FALSE. By default, each cell in a Tablix data region contains a text box so that the total number of text boxes that must be rendered can grow quickly.



For reports that have many images, set AutoSize on images to a different value such as Fit.



For text boxes, do not set the property TextAlign to General. This value requires conditional processing, depending on the text box content.



Do not use horizontal page breaks when they are not required. Review the margins, column widths, and white space in a report. For example, render the report to a .TIFF file and view it in the Microsoft Windows Picture and Fax viewer to determine whether additional pages are being rendered.



Set the KeepTogether property on Tablix members only when you must control the specific rendering behavior for a Tablix data region. The KeepTogether feature requires additional processing when page breaks are calculated.

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

Module 6: Upgrade Reports Add and Identify Hidden Fields If you have hidden fields on a report, it is recommended that you mark them so that they are easy to identify. Additionally, you might want to move hidden fields to a different location in the layout to avoid problems with formatting. To identify hidden fields, follow these steps. 1.

In the development environment, on the Tools menu, click Object Designer.

2.

In Object Designer, click Report, select the report to which you want to add a hidden field, and then click the Design button.

3.

On the View menu, click Layout.

4.

In Visual Studio Report Designer, on the View menu, click Toolbox.

5.

From the toolbox, under Report Items, drag a text box to the report layout.

Note: If the hidden text box is in a table data region, it is recommended that you insert a new row in the table and add the hidden text box to this new row. In the Properties window of the row, under Layout, you change the value of the Height property to a larger value so that you can view the row when you design the report. However, make sure that the value is not so large that it will cause formatting problems when you print the report, such as 0.2cm. 6.

Select the text box that you created. On the View menu, click the Properties window.

7.

In the Properties window, under Font, set the Color property to Yellow, or select the yellow square from the drop-down list.

8.

In the Properties window, under Position, expand Size, and then set the Width property to a small width, such as 0.15cm.

9.

In the Properties window, under Visibility, set the Hidden property to True.

10. On the File menu, click Save Report.rdlc.

Hide Nonfiltered Headers If you apply a filter to the data in a report, then it is recommended that you create an additional header row in the report to display the filter. You display this header row only if the user specifies a filter. If no filter is specified, then the filter header is not displayed. To conditionally display the filter header, you must add a filter variable to the report dataset. Next, in the RDLC report layout, create a conditional expression on the visibility of the filter header that uses the filter variable that you added to the dataset.

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

6 - 15

Reporting in Microsoft Dynamics® NAV 2013 An example of a report that uses additional header rows to display filter information is report 113, Customer/Item Sales. To hide non-filtered headers, follow these steps. 1.

In the development environment, on the Tools menu, click Object Designer.

2.

In Object Designer, click Report, select the report that you want to modify, and then click Design.

3.

On the View menu, click C/AL Globals.

4.

In the C/AL Globals window, on the Variables tab, add a new variable for the filter. The DataType of the variable is Text.

5.

On the View menu, click C/AL Code.

6.

In the C/AL Editor, in the OnPreReport trigger, add code to obtain the filters. For example, if you have a filter on the Customer table and the filter variable that you created is named CustFilter, then add the following code. CustFilter := Customer.GETFILTERS;

7.

In Report Dataset Designer, under the DataItem for the table to which a filter can be applied, add a new line.

8.

In the Data Type field of the new line, select Column.

9.

In the Data Source field of the new line, enter the name of the filter variable.

10. On the File menu, select Save. 11. In the Save dialog box, verify that Compiled is checked, and then click OK. 12. On the View menu, select Layout. 13. In Microsoft Visual Studio, in the Report.rdlc file, add a text box to display the filter header. 14. Select the filter header text box, and then on the View menu, select the Properties window. 15. In the Properties window, expand the Visibility field. 16. In the Hidden field, select from the drop-down list. 17. In the Expression window, create a conditional statement. For example, the following are the conditional statements for the two filter text boxes on report 113. =IIF(First(Fields!CustFilter.Value) = "",TRUE,FALSE) IIF(First(Fields!ItemLedgEntryFilter.Value) = "",TRUE,FALSE) 18. Save and compile the report.

6 - 16

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

Module 6: Upgrade Reports Build the Request Page After you upgrade the report to Microsoft Dynamics NAV 2013, you must create the request page. A request page runs before the report starts to execute. You can use a request page to specify options and filters for a report. You can design the Options FastTab of a request page by using Request Options Page Designer in the development environment. To access Request Options Page Designer, open Report Dataset Designer, click View, and then select Request Page. You can design the filters on request pages by using the following report properties: •

ReqFilterHeading



ReqFilterHeadingML



ReqFilterFields

You can also select the following actions on a request page: •

Print



Preview



Cancel



Help

The fields that you define as ReqFilterFields are shown on the request page. Additionally, an end-user can add more fields on which to filter to the request page. Best Practice: It is recommended that you add fields that the end-users of the report will frequently set filters on. By default, for every data item in the report, a FastTab for defining filters and sorting is created on the request page. To remove a FastTab from a request page, do not define any ReqFilterFields for the data item and set the DataItemTableView property to define sorting. The request page is displayed but there is no tab for this data item. If a DataItemTableView is not defined, then users can select a sort field and sort order at run time. If you set UseReqPage to No., then the report starts to print as soon as it is run. Here, end-users cannot cancel the report run. The report can be canceled. However, some pages might print.

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

6 - 17

Reporting in Microsoft Dynamics® NAV 2013 In a complex report that uses data from several tables, the functionality can depend on a specific key and sort order. Design your reports so that end-users cannot change the sort order in a way that affects the functionality of the report.

Determining which Reports to Upgrade This lesson will explain how to log report usage in Microsoft Dynamics NAV.

How to Log Report Usage You can use report usage logging to identify both frequently and rarely used reports in a customer installation. This information can be useful when you must determine which Classic reports should be transformed to RDLC reports. This only works in previous version(s) of Dynamics NAV. A custom development could be an alternative to this solution. To log report usage, you must have a hotfix installed. It can be downloaded here: Microsoft Dynamics NAV 5.0: KB2575296 KB2575296 http://go.microsoft.com/fwlink/?LinkId=267332 Dynamics NAV 2009: KB2558650 KB2558650 http://go.microsoft.com/fwlink/?LinkId=267333 After you install the required hotfix, to set up report usage logging, follow these steps. 1.

Create new table to be used to log report usage.

Code example OBJECT Table 50000 Report Log { OBJECT-PROPERTIES { Date=11-06-12;

6 - 18

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

Module 6: Upgrade Reports Time=12:36:58; Modified=Yes; Version List=NAV6; } PROPERTIES { } FIELDS { { 1 ; ;No. ;Integer ;AutoIncrement=Yes; MinValue=1 } { 2 ; ;User ID ;Code50 ;TableRelation="User Role"."Role ID"; CaptionML=ENU=User ID } { 3 ; ;Report ID ;Integer ;CaptionML=ENU=Report ID } { 4 ; ;Report Name ;Text249 ;FieldClass=FlowField; CalcFormula=Lookup(AllObjWithCaption."Object Caption" WHERE (Object Type=CONST(Report), Object ID=FIELD(Report ID))); CaptionML=ENU=Report Name } { 5 ; ;Date Time ;DateTime } } KEYS { { ;No. ;Clustered=Yes } } FIELDGROUPS

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

6 - 19

Reporting in Microsoft Dynamics® NAV 2013 { } CODE { BEGIN END. } } 2.

Open Codeunit 1.

3.

Open “C/AL Globals”.

4.

Browse to ”Functions”.

5.

Create a new function that uses the Name: OnReportRun.

6.

Open Properties and change ID to 120.

7.

Now open Locals and create the parameter= ReportId with Type=Integer.

8.

Select the Variables tab and create a ReportLog.

Now you must write the code for this new trigger. 9.

Open C/AL Editor and browse to the end.

10. In OnReportRun write the following code:

Code example ReportLog."User ID" := USERID; ReportLog."Report ID" := ReportId; ReportLog."Date Time" := CURRENTDATETIME; ReportLog.INSERT; 11. Now restart the Classic client. 12. Run several reports. 13. Now run the Report Log table to view the result.

6 - 20

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

Module 6: Upgrade Reports

Lab 6.1: Redesigning a Customer List Report Scenario Simon is a Microsoft Certified Partner working for CRONUS International Ltd. He is asked to upgrade the Classic version of the Customer List report that CRONUS used in earlier versions of Microsoft Dynamics NAV.

Exercise 1: Importing and Upgrading the Report Exercise Scenario Simon will upgrade the Classic report. This process deletes the request form, automatically creates an RDLC report layout, and upgrades the report to be valid for Microsoft Dynamics NAV 2013. Simon uses the following procedure to import a Classic-only report and upgrade it.

Task 1: Import the Report High Level Steps 1.

Import a Classic report.

Detailed Steps 1.

Import a Classic report. a.

In the development environment, on the Tools menu, click Object Designer.

b.

In Object Designer, on the File menu, click Import.

c.

In the Import Objects window, browse to the report object that contains only the Classic report layout (R101.fob), and then click Open.

d.

If you are prompted, click OK to open the Import worksheet to resolve any conflicts. Then click OK in the Import Worksheet to import the report.

Task 2: Upgrade the Report High Level Steps 1.

Upgrade a Classic report.

Detailed Steps 1.

Upgrade a Classic report. a.

In Object Designer, click Report, select Report 101, Customer List. This is the list that you imported in the previous step, and then click Upgrade Reports.

b.

In the dialog window, click Yes to confirm that you want to upgrade the report.

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

6 - 21

Reporting in Microsoft Dynamics® NAV 2013 c.

In the Tools menu, click Compile to compile the report that you upgraded in the previous step.

Exercise 2: Modifying the Customer List Report RDLC Layout Exercise Scenario Hidden fields in the RDLC report layout will cause formatting problems when Simon prints the report because these fields are outside the width of standard paper. To eliminate the formatting problems, Simon must move these hidden fields to another location on the report that is within the width of standard paper.

Task 1: Open the Report in Visual Studio Report Designer High Level Steps 1.

Open the report in Visual Studio Report Designer.

Detailed Steps 1.

Open the report in Visual Studio Report Designer. a.

In Object Designer, select report 101, click design, click View, and then click Layout.

b.

Visual Studio Report Designer opens.

Task 2: Move the hidden fields High Level Steps 1.

Move the hidden fields.

Detailed Steps 1.

Move the hidden fields. a.

In Visual Studio, in the Report.rdlc file that is created, in the Body section of the layout, select the following hidden fields on the right side of the table:

=FIELDS!COMPANYNAME.VALUE =FIELDS!Customer__ListCaption.VALUE =FIELDS!CurrReport_PAGENOCaption.Value

6 - 22

b.

Right-click the selected fields, and then click Cut.

c.

Right-click the row handle of the last row, and then click Insert Row Below to insert a new row in the table.

d.

Right-click the first field in the new row, and then click Paste.

e.

On the View menu, click the Properties window.

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

Module 6: Upgrade Reports f.

Select the new row. In the Properties window, under Layout, change the value of the Height property to 0.2 cm. The height 0.2 cm is sufficient to view the row in the layout, and it will not cause formatting problems when you print the report.

g.

This report has unsupported on the section trigger for Customer, Header (3). You must add the functionality for this code elsewhere in the report so that it will run in Dynamics NAV 2013. This is because code in a section trigger is not supported and will not be migrated.

Task 3: Add the Functionality from the Section Trigger High Level Steps 1.

Add the functionality from the section trigger.

Detailed Steps 1.

Add the functionality from the section trigger. a.

In Visual Studio, on the View menu, click the Properties window.

b.

In the Report.rdlc file, in the Body section of the layout, select the field at the top of the layout with the following value:

=First(Fields!Customer_TABLECAPTION__________CustFilter.Value) c.

In the drop-down list for the Hidden field, select .

d.

In the Expression window, enter the following expression:

=IIF(Fields!CustFilter.Value"",False,True) e.

Click OK.

Exercise 3: Add Captions and Labels to the Report Exercise Scenario In the upgraded report the captions are a part of the dataset. Mort will now optimize the report that has the property Include Caption and uses labels.

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

6 - 23

Reporting in Microsoft Dynamics® NAV 2013 Task 1: Change the Captions of the Report High Level Steps 1.

Enable the Include Caption property.

2.

Remove the ‘old’ caption fields from the dataset.

3.

In Visual Studio Report Designer replace the old caption fields by using the new captions.

Detailed Steps 1.

2.

Enable the Include Caption property. a.

In the Report Dataset Designer select the field that has the name Customer__No__ and then click Include Caption to enable it.

b.

Repeat this step for the following fields: Customer__Customer_Posting_Group_



Customer__Customer_Disc__Group_



Customer__Invoice_Disc__Code_



Customer__Customer_Price_Group_



Customer__Fin__Charge_Terms_Code_



Customer__Payment_Terms_Code_



Customer__Salesperson_Code_



Customer__Currency_Code_



Customer__Credit_Limit__LCY__



Customer__Balance__LCY__



Customer_Contact



Customer__Phone_No__



Customer__Balance__LCY___Control42

Remove the ‘old’ caption fields from the dataset. a.

6 - 24



In the Report Dataset Designer remove the following lines with the name: 

Customer__No__Caption



Customer__Customer_Posting_Group_Caption



Customer__Customer_Disc__Group_Caption



Customer__Invoice_Disc__Code_Caption



Customer__Customer_Price_Group_Caption



Customer__Fin__Charge_Terms_Code_Caption



Customer__Payment_Terms_Code_Caption



Customer__Salesperson_Code_Caption



Customer__Currency_Code_Caption

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

Module 6: Upgrade Reports

3.



Customer__Credit_Limit__LCY__Caption



Customer__Balance__LCY__Caption



Customer_ContactCaption



Customer__Phone_No__Caption

In Visual Studio Report Designer replace the old caption fields by using the new captions. a.

In Visual Studio Report Designer, in the first row of the table, right-click the text box that contains the expression: =First(Fields!Customer__No__Caption.Value) and replace it with the following expression: Parameters!Customer__No__Caption.Value

b.

Repeat this step for all text boxes in the first row of the label by using the corresponding parameter.

c.

Repeat this step also the two textboxes on the first column containing the fields: i.

=Fields!Customer_ContactCaption.Value becomes =Parameters!Customer_ContactCaption.Value

ii.

=Fields!Customer__Phone_No__Caption.Value becomes =Parameters!Customer__Phone_No__Caption.Value

Task 2: Use Labels in the Report High Level Steps 1.

In the Report Label Designer add labels.

2.

In Visual Studio Report Designer replace the old caption fields by using the new labels.

Detailed Steps 1.

2.

In the Report Label Designer add labels. a.

Add a label with the Name: Total__LCY_CaptionLbl and Caption: .

b.

Remove the corresponding line in the Report Dataset Designer.

In Visual Studio Report Designer replace the old caption fields by using the new labels. a.

In Visual Studio Report Designer change the expression of the text box that contains: =First(Fields!Total__LCY_Caption.Value) to Parameters!Total__LCY_CaptionLbl.Value

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

6 - 25

Reporting in Microsoft Dynamics® NAV 2013 Exercise 4: Saving the RDLC Report Layout Exercise Scenario Simon must save the RDLC layout, and he must also save and compile the changes in the Microsoft Dynamics NAV 2013 development environment.

Task 1: Save the RDLC Layout High Level Steps 1.

Save the report.

Detailed Steps 1.

Save the report. a.

In Visual Studio, on the File menu, click Save report.rdlc.

b.

Close Visual Studio.

c.

In the Microsoft Dynamics NAV 2013 development environment, select an empty line in Report Dataset Designer. You receive the following message: The layout of report id: '101' is changed by another application. Filename of the changed RDLC: Do you want to load the changes?

6 - 26

d.

Click Yes to load the changes that you made to the RDLC report layout.

e.

On the File menu, click Save.

f.

In the Save dialog box, select Compiled, and then click OK.

g.

Close the report in Object Designer.

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

Module 6: Upgrade Reports

Lab 6.2: Redesigning a Customer - Order Summary Report Scenario Simon is a Microsoft Certified Partner working for CRONUS International Ltd. He is asked to upgrade the Classic version of the Customer - Order Summary report that CRONUS used in the earlier version of Microsoft Dynamics NAV.

Objectives •

Import and upgrade a report that has only a Classic report layout to a Microsoft Dynamics NAV 2013 report that has an RDLC layout.



Modify the RDLC report layout.



Save the layout and compile the report.

Exercise 1: Importing and Upgrading the Report Exercise Scenario Simon will now upgrade the Classic report. This process will delete the request form, automatically, create an RDLC report layout, and upgrade the report to be valid for Microsoft Dynamics NAV 2013.

Task 1: Import and Upgrade a Classic Report High Level Steps 1.

Import a Classic report.

Detailed Steps 1.

Import a Classic report. a.

In the development environment, on the Tools menu, click Object Designer.

b.

In Object Designer, on the File menu, click Import.

c.

In the Import Objects window, browse to the report object that contains only the Classic report layout for report R123456707, and then click Open.

d.

If you are prompted, click OK to open the Import worksheet to resolve any conflicts.

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

6 - 27

Reporting in Microsoft Dynamics® NAV 2013 Task 2: Upgrade a Classic Report High Level Steps 1.

Upgrade a Classic report.

Detailed Steps 1.

Upgrade a Classic report. a.

In Object Designer, click Report, select Report 123456707, Customer Order Summary (this is the report that you imported in the previous step), and then click Tools, Upgrade Reports.

b.

In the dialog window, click Yes to confirm that you want to upgrade the report.

c.

In the Tools menu, click Compile to compile the report that you upgraded in the previous step.

The “Customer – Order Summary Print Preview” illustration shows the RDLC report layout for report 123456707, Customer Order Summary, after you upgrade the report but before you perform any manual modifications.

6 - 28

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

Module 6: Upgrade Reports Exercise 2: Modifying the Customer - Order Summary Report RDLC Layout Exercise Scenario The RDLC report layout for the Customer Order Summary report that is created when Simon upgraded the report does not contain all the lines that are required to be displayed in the report. Simon must make some modifications to the report layout.

Task 1: Open the Report in Visual Studio Report Designer High Level Steps 1.

Open the report in Visual Studio Report Designer.

Detailed Steps 1.

Open the report in Visual Studio Report Designer. a.

In Object Designer, select report 123456707, click Design, click View, and then click Layout.

b.

Visual Studio Report Designer opens.

Task 2: Move Header Fields Out of the Table High Level Steps 1.

Move header fields out of the table.

Detailed Steps 1.

Move header fields out of the table. a.

In Visual Studio, in the Body of the report.rdlc file, move the table down in the layout to provide space for two fields in the table.

b.

Select the First(Fields!Outstanding_OrdersCaption.Value) field, right-click the field, and then click Cut.

c.

Right-click the area in the table and then click Paste to paste the First(Fields!Outstanding_OrdersCaption.Value) value in a text box that is in the table.

d.

Select the First(Fields!EmptyString.Value) field, right-click, and then select Cut.

e.

Right-click the area that is in the table, under the text box in which you performed the previous past operation and then click Paste to paste the First(Fields!EmptyString.Value) value in a text box.

f.

Select the first two rows of the table from which you cut fields. Right-click the row handle of the two rows, and then select Delete Rows.

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

6 - 29

Reporting in Microsoft Dynamics® NAV 2013 The layout that is created automatically contains some fields that you must move. The first field is the SalesAmtOnOrderLCY_3_.Value field. This field is in the wrong location. The other fields that can cause problems in the printed layout of the report are the three hidden fields.

Task 3: Update the Layout High Level Steps 1.

Update the layout.

Detailed Steps 1.

Update the layout. a.

In Visual Studio, on the last row of the table, right-click the field that uses the value =Sum(Fields!SalesAmtOnOrderLCY_3_.Value), and then click Cut.

b.

Right-click the empty field in the last row of the table that is between the =Sum(Fields!SalesAmtOnOrderLCY_2_.Value) and =Sum(Fields!SalesAmtOnOrderLCY_4_.Value) fields, and then click Paste.

c.

Expand the third row of the table.

d.

Decrease the width of the third column of the table.

e.

Select the three hidden fields on the third row of the table. These hidden fields are in the rightmost columns of the table. The values in the hidden fields are as follows:

=Fields!COMPANYNAME.Value =Fields!Customer__Order_SummaryCaption.Value =Fields!CurrReport_PAGENOCaption.Value f.

Right-click the three hidden fields, and then click Cut.

g.

Right-click the empty field in the first column of the second row of the table, and then click Paste to paste the three fields.

Note: It is recommended that you move these hidden fields from the right side of the table in all reports for which you create an RDLC report layout. Although the fields are hidden, white space is still allocated on the page for the fields. In some cases, this causes problems with the print layout because of the width of the paper and the width of the table.

6 - 30

h.

Select the last three columns of the table from which you cut the hidden fields.

i.

Right-click the three columns, and then click Delete Columns.

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

Module 6: Upgrade Reports The next step is to add detail lines and add data to those lines in the table so that the same information that is in the Classic client report layout is in the RDLC report layout.

Task 4: Add Data to Detail Lines High Level Steps 1.

Add data to detail lines.

2.

Obtain the sum of the lines in the dataset for each customer, by adding a grouping property. Add the grouping property for each detail row that you added.

3.

Use the request page to select if the values should be displayed in local currency (LCY) or in the company's own currency. The first detail line that you added in step 3 shows the values in the local currency. The second detail line shows the values in the company's currency. Then select which values will be printed in the report that is based on the selection in the request page, you must add a conditional statement to the visibility property. Now set the visibility property.

4.

Show the All Amounts are in the LCY caption only when the values are displayed in local currency.

5.

Show the customer filter caption only when a customer filter is applied.

Detailed Steps 1.

Add data to detail lines. a.

Click in the table to make it active.

b.

Right-click the blank detail row, and then click Insert Row > Inside Group - Below.

c.

Add the following values to the first blank detail line: i.

Customer_No_

ii.

Customer_Name

iii. Leave the third column blank. iv. SalesAmtOnOrderLCY_1_Control31 v.

SalesAmtOnOrderLCY_2_Control32

vi. SalesAmtOnOrderLCY_3_Control33 vii. SalesAmtOnOrderLCY_4_Control34 viii. SalesAmtOnOrderLCY_5_Control35 ix. SalesOrderAmountLCY_Control36 To add these values, follow these steps. d.

Right-click the field of the detail line, and then click Expression.

e.

In the Expression window, under Category, select Fields (DataSet_Result).

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

6 - 31

Reporting in Microsoft Dynamics® NAV 2013 f.

Under Field, double-click the value from the previous list.

g.

An expression is added to the text box.

For each amount value, the data that is shown must be the sum of the lines in the dataset. h.

To create the sum, change the expression to Sum(). For example, change =Fields!SalesAmtOnOrderLCY_1_Control31.Value to =Sum(Fields!SalesAmtOnOrderLCY_1_Control31.Value)

i.

Click OK.

j.

For each value, you must modify the font and the format.

To format the data, follow these steps. k.

Right-click the field, and then click Properties.

l.

In the Text box Properties window, click the Number tab.

m. If the field is an amount field, click Custom in Category and next to Custom format, click the Expression button. n.

In the Expression window, under Category, select Fields (DataSet_Result).

o.

Under Fields, select the Format value of the field that you selected. For example, select SalesAmtOnOrderLCY_1_Control31Format.

p.

Click OK.

q.

In the Textbox Properties window, click the Font tab.

r.

Under Size, enter 7pt.

s.

Add the following values to the second blank detail line: i.

Customer_No_

ii.

Customer_Name

iii. Sales_Line__Currency_Code_ iv. SalesAmtOnOrder_1_ v.

SalesAmtOnOrder_2_

vi. SalesAmtOnOrder_3_ vii. SalesAmtOnOrder_4_ viii. SalesAmtOnOrder_5_ ix. SalesOrderAmount 2.

6 - 32

Obtain the sum of the lines in the dataset for each customer, by adding a grouping property. Add the grouping property for each detail row that you added. a.

Select the row.

b.

In the Row Groups window, select Group Properties.

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

Module 6: Upgrade Reports

3.

c.

In the Properties window, click the Add button.

d.

In the Group on field select Fields!Customer_No_.Value, and then click OK.

Use the request page to select if the values should be displayed in local currency (LCY) or in the company's own currency. The first detail line that you added in step 3 shows the values in the local currency. The second detail line shows the values in the company's currency. Then select which values will be printed in the report that is based on the selection in the request page, you must add a conditional statement to the visibility property. Now set the visibility property. a.

Select the first of the two rows that you added. This row has the LCY values. In the Properties window, expand Visibility. In the drop-down list for Hidden, select .

b.

In the Expression window, change the expression to the following so that the row is hidden if Fields!PrintAmountsInLCY.Value is not true:

= not first(Fields!PrintAmountsInLCY.Value) c.

Select the second of the two rows that you added. This row does not have the LCY values.

d.

In the Properties window, expand Visibility.

e.

In the drop-down list for Hidden, select .

f.

In the Expression window, change the expression to the following:

=first(Fields!PrintAmountsInLCY.Value) 4.

Show the All Amounts are in the LCY caption only when the values are displayed in local currency. a.

Right-click the field =First(Fields!All_Amounts_are_in_LCYCaption.Value), and then select Properties.

b.

In the Textbox Properties window, click the Visibility tab.

c.

Under Initial visibility, select Expression, and then enter the following expression in the text box:

=not First(Fields!PrintAmountsInLCY.Value) d.

Click OK.

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

6 - 33

Reporting in Microsoft Dynamics® NAV 2013 5.

Show the customer filter caption only when a customer filter is applied. a.

Right-click the field =First(Fields!Customer_TABLECAPTION__________CustFilter.Va lue), and then click Properties.

b.

In the Textbox Properties window, click the Visibility tab.

c.

Under Initial visibility, select Expression, and then enter the following expression in the text box:

=First(Fields!CustFilter.Value, "DataSet_Result")= ""

Exercise 3: Saving the RDLC Report Layout Exercise Scenario Simon must now save the RDLC report layout, and he must also save and compile the changes in the Microsoft Dynamics NAV 2013 development environment.

Task 1: Save the Report High Level Steps 1.

Save the report.

Detailed Steps 1.

Save the report. a.

In Visual Studio, on the File menu, click Save report.rdlc.

b.

Close Visual Studio.

c.

In the Microsoft Dynamics NAV 2013 development environment, select an empty line in the report in Object Designer. You receive the following message: The layout of report id: '123456707' is changed by another application. Filename of the changed RDLC: Do you want to load the changes?

6 - 34

d.

Click Yes to load the changes that you made to the RDLC report layout.

e.

On the File menu, click Save.

f.

In the Save window, select the Compiled check box, and then click OK.

g.

Close the report in Object Designer.

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

Module 6: Upgrade Reports

Module Review Module Review and Takeaways This module described the upgrade process for different report types: •

A Hybrid Report



A Processing Only Report



A Classic Report

Furthermore several tips, tricks and recommendations were provided concerning performance and optimization of the dataset and report layout. The module also covered how to determine which reports to upgrade and concluded with practical labs and real life examples on how a List report and an Order Summary report should be upgraded.

Test Your Knowledge Test your knowledge with the following questions. 1.

Which report types cannot be upgraded to Microsoft Dynamics NAV 2013? ( ) Classic ( ) Hybrid ( ) Textual ( ) ProcessingOnly

2.

Which menu item is used to upgrade a report to the Microsoft Dynamics NAV 2013 RoleTailored client? ( ) Tools > Upgrade Reports ( ) Tools > Report Upgrade ( ) View > Layout ( ) View > Upgrade Report

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

6 - 35

Reporting in Microsoft Dynamics® NAV 2013 3.

How is report usage logged in Microsoft Dynamics NAV? ( ) Report usage is logged automatically. ( ) Report usage is logged through the change log functionality. ( ) A hotfix must be installed , depending on the version of Microsoft Dynamics NAV, after which you can create a log table and modify a Codeunit 1. ( ) Report usage cannot be logged in Microsoft Dynamics NAV.

6 - 36

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

Module 6: Upgrade Reports

Test Your Knowledge Solutions Module Review and Takeaways 1.

Which report types cannot be upgraded to Microsoft Dynamics NAV 2013? ( ) Classic ( ) Hybrid (√) Textual ( ) ProcessingOnly

2.

Which menu item is used to upgrade a report to the Microsoft Dynamics NAV 2013 RoleTailored client? (√) Tools > Upgrade Reports ( ) Tools > Report Upgrade ( ) View > Layout ( ) View > Upgrade Report

3.

How is report usage logged in Microsoft Dynamics NAV? ( ) Report usage is logged automatically. ( ) Report usage is logged through the change log functionality. (√) A hotfix must be installed , depending on the version of Microsoft Dynamics NAV, after which you can create a log table and modify a Codeunit 1. ( ) Report usage cannot be logged in Microsoft Dynamics NAV

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

6 - 37

Reporting in Microsoft Dynamics® NAV 2013

6 - 38

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

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF