You can create reports that provide dynamic data with Visual Studio Report Designer and Microsoft Dynamics NAV 2009. Your reports can include images, graphics, toggles on data columns, interactive sorting, and links to other data in the system. This walkthrough illustrates how to set up a report to include a link to the customer card page. When the report is run in preview mode, you can look up any existing customer directly from the report. By including this functionality, you now have a report that is a dynamic list that you can use to drill down into data instead of a report that is a static, printed list.
About This Walkthrough
The walkthrough provides an overview of how to modify the Customer - Top 10 List report to include a link to the customer card. This walkthrough illustrates the following tasks:
-
Enabling hyperlinks on a report.
-
Adding a variable and code to the Customer - Top 10 List report definition.
-
Adding a text box to the Customer - Top 10 List report layout.
-
Adding a link to the customer name on the report using Visual Studio.
-
Running the modified report.
Prerequisites
To complete this walkthrough, you will need:
-
Microsoft Dynamics NAV 2009 with a developer license.
-
The CRONUS International Ltd. demo data company.
-
Visual Studio. For more information about versions of Visual Studio that you can use, see Requirements for Developing Reports for the RoleTailored Client.
Enabling Hyperlinks on a Report
Before you can add a link from a report to a page, you must enable hyperlinks on the report. For more information, see EnableHyperlinks Property.
To enable hyperlinks on a report
-
In the Classic client, on the Tools menu, click Object Designer.
-
In Object Designer, click Report, select report 111, the Customer - Top 10 List report, and then click Design.
-
In Report Designer, select an empty line.
-
On the View menu, click Properties.
-
In the Properties window, in the EnableHyperlinks field, select Yes.
-
Save and compile the report.
Adding a Variable and Code to the Report
In the following procedure, you will add a variable that holds a reference to the current customer record in the report.
To add a variable and code to the report
-
In the Classic client, on the Tools menu, click Object Designer.
-
In Object Designer, click Report, and then locate the Customer - Top 10 List report by typing object ID 111.
-
Select the Customer - Top 10 List report, and then click the Design button.
-
In Report Designer, select the Customer data item, and then on the View menu, click C/AL Globals.
-
On the Variables tab, add a new entry. In the Name field, enter CustomerRecRef, and in the DataType field, select RecordRef.
-
Close the C/AL Globals window.
-
In Report Designer with the Customer data item still selected, on the View menu, click C/AL Code.
-
In the C/AL Editor window, on the
OnPreDataItem
trigger, add the following line of code:Copy Code CustomerRecRef.OPEN(18);
-
In Report Designer, change focus to the Integer data item.
-
In the C/AL Editor window, on the
OnAfterGetRecord
trigger, add the following line of code:Copy Code CustomerRecRef.SETPOSITION(Customer.GETPOSITION);
-
Close the C/AL Editor window and save the report.
Adding a Text Box to the Report
After creating the CustomerRecRef
variable, you
must create a new text box that is used to get the value of the
current customer that is represented in the dataset in Visual
Studio once the layout is opened there. The text box is not visible
on the report when it is run but is only used for layout purposes.
For more information, see How to: Resolve
Formatting Issues Caused by Hidden Fields. The following
steps illustrate how to add the text box to the report.
To add a text box to the report
-
With the Customer - Top 10 List report open in Report Designer, on the View menu, click Sections.
-
In Section Designer, locate the BarText text box, and then resize it to make room for a new small text box.
-
On the View menu, click Toolbox.
-
Click Textbox and then click on the report design to place it next to the BarText text box.
-
Right-click the new Textbox, and then click Properties.
-
In the Properties window, on the SourceExpr property, enter the following expression:
FORMAT(CustomerRecRef.RECORDID,0,10)
-
Close the Properties window.
Note The usage of value 10 in this expression is a RoleTailored client feature only that will format
RECORDID
into a text representation that is compatible with the URL handler of reports and pages. -
Save and compile the report.
Adding a Link to Customer Name in Visual Studio
Once you have created the variable and text box with Report Designer, you can open and modify the layout of the report in Visual Studio. The following steps will add a link to the customer name on the report that opens the customer card for the selected customer. The text box that you created in Microsoft Dynamics NAV is part of the dataset in Visual Studio under Data Sources, and its value is referenced in the link you are adding.
To add a link to customer name in Visual Studio
-
In the Classic client, with the Customer - Top 10 List report open in Report Designer, on the View menu, click Layout.
-
In Visual Studio, in the Body section of the report, locate the Customer_Name text box. The value of the textbox is
=Fields!Customer_Name.Value
. -
Right-click the textbox, and then click Properties.
-
In the Properties window, click the Navigation tab.
-
Select the Jump to URL check box and enter the following line in the field below:
="dynamicsnav:////runpage?page=21&mode=edit&bookmark="+Fields!FORMAT_CustomerRecRef_RECORDID_0_10_.Value
Note This line opens the page in edit mode.
-
Click OK to close the window.
-
Save the report in Visual Studio and return to the Classic client.
Running the Modified Report
In the Classic client, you must now save the modified report and compile it before it can be run.
To run the modified report
-
In the Classic client, save the Customer - Top 10 List report. A message informs you that the .rdlc file for this report has changed and asks if you want to load the changes. Click Yes to save the changes in the database.
-
On the Tools menu, click Compile to compile the report.
-
On the Windows taskbar, click Start, and then click Run.
-
In the Run window, enter the following text: dynamicsnav:////runreport?report=111, and then click OK.
-
Click Preview to view the report. The report lists the top 10 list of customers. If you hover on the customer name, then you will get a link to open the specific customer on a separate customer card. This makes it possible to drill down into the customer's data.
See Also
© 2010 Microsoft Corporation. All rights reserved.