Your SlideShare is downloading. ×
Na2009 enus rep_05
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Na2009 enus rep_05

1,732

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,732
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
35
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Chapter 5: Running ReportsCHAPTER 5: RUNNING REPORTSObjectives The objectives are: • Use the features of the ReportViewer control. • Examine how to add a report to a page and the Departments section. • Examine how to create and run hyperlinks to reports from the command prompt, the Start menu, the Desktop and Microsoft Internet Explorer. • Understand how to create a hyperlink to a page in the RoleTailored client • Understand how to create a hyperlink to a page in a RoleTailored client report. • Explore where to find additional resources and information about reporting.Introduction In Microsoft Dynamics® NAV 2009, reports can be incorporated into menus, or they can be called from, for example, a command button on a form or page. When designing reports, you will often want to run them before they are integrated into the application. In the previous chapters, reports were run from the Start menu. This chapter will show how to integrate the reports into the RoleTailored client interface and how to create hyperlinks to reports. Microsoft Official Training Materials for Microsoft Dynamics ® 5-1 Your use of this content is subject to your current services agreement
  • 2. Report Design in Microsoft Dynamics® NAV 2009The ReportViewer Control Microsoft Visual Studio® 2005 and 2008 include report design functionality and ReportViewer controls so that you can add full-featured reports to custom applications. Reports can contain tabular, aggregated, and multidimensional data. ReportViewer controls are provided so that you can process and display the report in your application. There are two versions of the control. The ReportViewer Web server control is used to host reports in ASP.NET projects. The ReportViewer Windows Forms control is used to host reports in Windows® application projects. The ReportViewer control processes .rdlc files. Both controls can be configured to run in local processing mode or remote processing mode. How you configure the processing mode affects everything about the report from design to deployment. • Local processing mode refers to report processing that is performed by the ReportViewer control in the client application. All report processing is performed as a local process using data that your application provides. To create the reports used in local processing mode, use the Report project template in Visual Studio. • Remote processing mode refers to report processing that is performed by a Microsoft SQL Server® 2005 Reporting Services report server. In remote processing mode, the ReportViewer control is used as a viewer to display a predefined report that is already published on a Reporting Services report server. All processing from data retrieval to report rendering is performed on the report server. To use remote processing mode, you must have a licensed copy of SQL Server 2005 Reporting Services. Microsoft Dynamics NAV 2009 uses the ReportViewer 2008 Windows Forms control in local processing mode. ReportViewer Toolbar The ReportViewer control includes a toolbar that provides navigation, search, export, and print functionality so that you can work with reports in a deployed application. FIGURE 5.1 THE REPORTVIEWER TOOLBAR5-2 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 3. Chapter 5: Running Reports Document Maps The ReportViewer toolbar includes an icon used to toggle a document map on a report. A document map is a navigation area that is attached to the left side of the report view area. It contains a list of links that users can click to navigate to a specific area of the report. Not all reports have a document map; you must define one in the report definition to use this feature. For more information about document maps and other interactive report features, refer to Chapter 2. Stopping and Refreshing a Report You can use the Refresh and Stop buttons to trigger or stop report rendering. If you click Refresh for a server report that is processed remotely, the report server reprocesses the report with the most recent data. Note that report execution options that are configured on the report determine whether data is actually refreshed or retrieved from cache. The control does not check server report properties, so you must find out from the report server administrator whether the report is configured to use live data. Refresh behavior differs for local processing mode. Because locally processed reports use data that is provided by your application, it is assumed that application code is handling refresh operations. To use the Refresh button on the toolbar, you must provide code that handles the Refresh event. If you do not handle this event, clicking Refresh has no effect. As Microsoft Dynamics NAV 2009 uses local processing, the Refresh functionality will not be available. The Stop button can be used to stop a report when testing RDLC reports or when an RDLC report has slow performance. Zooming the Report Page The ReportViewer toolbar provides standard zoom functionality so that you can enlarge or shrink the report. Searching a Report The ReportViewer toolbar includes a search field so that you can find specific text within a report. Search for content in the report by typing a word or phrase that you want to find. The search is case-insensitive and begins at the page or section that is currently selected. Wildcards and Boolean search operators are not supported. Only visible content is included in a search operation. If the report uses show / hide functionality, hidden content is not exposed through search operations. To search for subsequent occurrences of the same value, click Next. Microsoft Official Training Materials for Microsoft Dynamics ® 5-3Your use of this content is subject to your current services agreement
  • 4. Report Design in Microsoft Dynamics® NAV 2009 Previewing a Report and Setting Page Sizes The ReportViewer toolbar in the Windows Forms control includes commands for viewing a report in print layout and setting page sizes. When you click Print Layout, the ReportViewer toolbar is updated to show just the commands that you can use during preview. Print Layout is a toggle command. You can switch between preview and report session by clicking this button. When clicking Page Size, you can specify page dimensions that are used only for print output. The page dimensions are initialized with values from the report definition, but you can override the values for printing purposes. You cannot save the values with the report. Exporting a Report The ReportViewer toolbar provides export formats so that you can save a report as an Excel or PDF application file. The same report can have a different appearance and functionality depending on the rendering format you select. Reports that have links, document maps, and bookmarks might not function properly once the report is saved to a file. Depending on how items are aligned in a report, the report layout in a different file format might include extra pages or white space that you did not expect. Printing a Report The ReportViewer toolbar provides print support. Print support is implemented differently for each version of the control and the processing mode you use. Printing reports from the Windows Forms control uses the print functionality of the operating system.Print a Report from the RoleTailored Client After a report is created and designed using Visual Studio, you can add the report to the interface of the RoleTailored client to make it available to the end-users. Reports can be added in several ways: in the Action Pane of a page, in the Role Center menu, in the Activities page of a Role Center or in the Departments section. Adding Reports to a Page The following procedure explains how to make a report available in the RoleTailored client by adding the report to the promoted actions pane in the Item List page. 1. In the Microsoft Dynamics NAV Classic client, open Object Designer, and then click Page. 2. Select the page to display the report, for example, Page 31, Item List. 3. Click Design to open the page in Page Designer.5-4 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 5. Chapter 5: Running Reports 4. Select an empty line in the designer. Click View, and then Actions to open Action Designer. 5. Scroll down to the ActionContainer that has Reports as its subtype. 6. Select the line that has Inventory - List as its caption. 7. Press F3 to insert a new empty line (or select Edit, New). 8. On the new line, add an action to the list. 9. In the Caption field enter a name for the action: Inventory Matrix. 10. In the Type field, select Action. 11. Click View, and then Properties to open the Properties window for the new action. 12. In the Value field of the RunObject property, click the drop-down arrow and select report 123456701 in the Object List window. 13. In the Properties window, set the Promoted property to Yes, and set the PromotedCategory property to Report. 14. Compile and save the page. 15. Open the RoleTailored client and then open the Item List page. FIGURE 5.2 THE NEW REPORT IS ADDED TO A PAGE. The report is added to the list of promoted actions. Click the action to run the report. The report is also available in the Reports menu that appears right above the actions pane. Microsoft Official Training Materials for Microsoft Dynamics ® 5-5Your use of this content is subject to your current services agreement
  • 6. Report Design in Microsoft Dynamics® NAV 2009 Demonstration: Adding Reports to a Role Center Menu Ellen wants the Inventory Matrix report to be available for her colleague John. Mort will add it to the menu of Johns Role Center. 1. In the Microsoft Dynamics NAV Classic client, open Object Designer. 2. Click the Page button. 3. Select page 9009, Whse. Worker WMS Role Center. 4. Click Design to open the page in Page Designer. 5. Select an empty line in the designer. Click View, and then Actions to open Action Designer. 6. Scroll down to the Action that has Customer Labels as its Caption. 7. Click the Separator button to insert a separator. 8. Move the cursor one line down. 9. Press F3 to insert a new empty line (or select Edit, New). 10. On the new line, in the Caption field, enter a name for the action: Inventory Matrix. 11. In the Type field, select Action. 12. Click View, and then Properties to open the Properties window for the new action. 13. In the Value field of the RunObject property, click the drop-down arrow and select report 123456701 in the Object List window.5-6 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 7. Chapter 5: Running Reports 14. Compile and save the page. 15. Open the RoleTailored client. 16. In the navigation pane, click the Role Center page. FIGURE 5.3 THE NEW REPORT IS ADDED TO THE ROLE CENTER MENU. Now the report is added to the role center menu. Click the action to run the report. Demonstration: Adding Reports to the Role Center Activities John is not that experienced with computers. He regularly calls Mort to ask where he can find the Inventory Matrix report. To help John, Mort will make the report accessible as a link on the Role Center page. 1. In the Microsoft Dynamics NAV Classic client, open Object Designer. 2. Click the Page button. 3. Select page 9056, Warehouse Worker Activities. 4. Click Design to open the page in Page Designer. 5. Scroll down to the Group that has Internal as its Caption. 6. Select View, Actions. 7. On the first empty line, in the Caption field, enter a name for the action: Print Inventory Matrix. 8. In the Type field, select Action. Microsoft Official Training Materials for Microsoft Dynamics ® 5-7Your use of this content is subject to your current services agreement
  • 8. Report Design in Microsoft Dynamics® NAV 2009 9. Click View, and then Properties to open the Properties window for the new action. 10. In the Value field of the RunObject property, click the drop-down arrow and select report 123456701 in the Object List window. 11. Compile and save the page. 12. Open the RoleTailored client and then open the Role Center page. FIGURE 5.4 THE NEW REPORT IS ADDED TO THE ACTIVITIES PAGE. Now the report is added to the Internal group in the Role Center page. Click the action to run the report. Adding Reports to a Departments Section In Microsoft Dynamics NAV 2009, navigation through the application is done through the use of the Navigation Pane, which is made of MenuSuite objects. MenuSuite objects contain the main menu content that is displayed in the Navigation Pane (in the Classic client) and in the Departments Page (in the RoleTailored client) and have a layered structure. In the Classic client, application objects, such as forms and reports, are accessed from the Navigation Pane. In the RoleTailored client, application objects, such as pages and reports, are accessed from either the Departments page or the Role Center page. The Departments item in the navigation pane of the RoleTailored client provides links to all the pages of the RoleTailored client. The links and pages under5-8 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 9. Chapter 5: Running Reports Departments are generated automatically based on the menu suite of the RoleTailored client user. In this way, the Departments page in the RoleTailored client is similar to the Navigation Pane in the Classic client: • It gives access to reports and forms or pages. • It is built using MenuSuite objects. Unlike any other application objects, the ID of the MenuSuite is defined by C/SIDE depending on the target client and the MenuSuite level. The ID of a MenuSuite for the RoleTailored client is the ID of the MenuSuite for the Classic client with the same level, plus 1000, as shown in the following table. Level MenuSuite Object in the MenuSuite Object in the Classic Client RoleTailored Client MBS 10 MBS 1010 Dept - MBS Add- 51 Add-on 1 1051 Dept - Add-on 1 on 1 Compa 90 Company 1090 Dept - Company ny To modify the Navigation Pane or the Departments Page, you can design the existing or create new MenuSuite objects in the classic client. When creating a new MenuSuite object, you have to select both the target client and the menu level. FIGURE 5.5 THE DESIGN LEVEL WINDOW Microsoft Official Training Materials for Microsoft Dynamics ® 5-9Your use of this content is subject to your current services agreement
  • 10. Report Design in Microsoft Dynamics® NAV 2009 MenuSuites for the RoleTailored client are created and designed in the same way as MenuSuite objects for the classic client. However, when you create menu groups in the MenuSuite for the RoleTailored client, a new property Department Page is available. FIGURE 5.6 THE GROUP PROPERTIES WINDOW The Department Page property indicates whether to separate a menu page (containing the underlying menu groups and items) to be built for the group and whether the group needs to appear in the menu structure in the RoleTailored client. When adding menu items to a MenuSuite for the RoleTailored client, you have to specify the Department Category which the menu item belongs to. There are six categories: Lists, Tasks, Reports and Analysis, Documents, History, Administration. The property is used to automatically generate the navigation structure for the RoleTailored client. Demonstration: Adding Reports to a Departments Section Prakash wants to print the Job Actual To Budget Chart Report (123456709). Instead of printing it through the use of the Start menu, he asks Mort to integrate the report in the Job menu on the Departments section. Mort will first create a new MenuSuite object. 1. In the Microsoft Dynamics NAV Classic client, open Object Designer. 2. Click the MenuSuite button. 3. Click the New button to open the Design Level window. 4. In the Design For field, select RoleTailored Client. 5. In the listbox, select the Dept - Partner level. 6. In the Navigation Pane Designer, select the Jobs menu. 7. Expand the Reports menu group and select the last report in the group: Jobs per Item. 8. Right-click the menu item and choose Create Item. 9. In the Object Type field, select Report. 10. In the Object ID field, click the drop-down arrow and select report 123456709 in the Object List window. 11. In the Caption field, change the caption to Job Actual to Budget - Chart.5-10 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 11. Chapter 5: Running Reports 12. In the Department Category field, select Reports and Analysis. 13. Click OK to close the Create Item window. 14. Compile and save the MenuSuite. 15. Open the RoleTailored client and then open the Departments page. 16. Click the Jobs item. Now the new report is added to the Reports and Analysis category: FIGURE 5.7 REPORT ADDED TO THE DEPARTMENTS SECTIONHyperlinks to Reports Hyperlinks allow users to send or save quick links to specific pages in Microsoft Dynamics NAV. For example, you can create a hyperlink to a specific list page, such as Customers. This lesson explains how to create and run hyperlinks to reports. Create Hyperlinks To create a hyperlink, type the Microsoft Dynamics NAV executable service and then type the syntax for the hyperlink. For example: Microsoft.Dynamics.Nav.Client.exe "DynamicsNAV://MyServer/DynamicsNAV/CRONUS International Ltd./RunPage?Page=22" This example specifies a server name, service, company, and page ID. If entered correctly it opens the RoleTailored client on page 22, the customer list page. Microsoft Official Training Materials for Microsoft Dynamics ® 5-11 Your use of this content is subject to your current services agreement
  • 12. Report Design in Microsoft Dynamics® NAV 2009 Building a URL When you build a hyperlink URL, it can be structured in the following three ways: • DynamicsNAV://server/service/company/runpage?page=22&bookm ark=0ABA0700235752C7D1 • DynamicsNAV://server/service/company/runreport?report=901 • DynamicsNAV://server/service/company/navigate?node=Home/Item s You can also specify the following additional parameters in a URL. Parameter Description Personalization Specifies the unique identification used in personalization ID to store settings in the User Metadata table. If a personalization ID is not found, the page is launched without personalization. Example: DynamicsNAV://localhost/DynamicsNAV/CRONUS International Ltd./runpage?page=22&personalization= 0000232e-0000-001a-0008-0000836bd2d2 Bookmark Positions the cursor on a single record in a table. Only automatically generated bookmarks are used. If an incorrect bookmark is entered, you will get an error message. Example: DynamicsNAV://localhost/DynamicsNAV/CRONUS International Ltd./runpage?page=22&bookmark= 120000000089083237343 Mode Used to open a page in a specific mode. Other modes include: view, edit, create, select, and delete. Example: DynamicsNAV://localhost/DynamicsNAV/CRONUS International Ltd./runpage?page=22&mode=View5-12 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 13. Chapter 5: Running Reports Syntax for Creating Hyperlinks The following table shows some examples of hyperlinks and provides information about how to specify parameters. Parameters Description Syntax Company Allows you to switch a DynamicsNAV:////<CompanyNa Name company (case sensitive). me>/RunPage?Page=<pageid> Example: Microsoft.Dynamics.Nav.Client.e xe "DynamicsNAV:////CRONUS International Ltd./RunPage?Page=22" Navigate Allows users to send or DynamicsNAV://///navigate?nod save quick links to specific e=<service> pages. Example: Microsoft.Dynamics.Nav.Client.e xe DynamicsNAV://///navigate?nod e=Home/"User Setup" RunPage Allows you to run a DynamicsNAV:////runpage?page specific page for testing =<page id> purposes. Example: DynamicsNAV:////runpage?page =42 RunReport Allows you to run a DynamicsNAV:////runreport?repo specific report for testing rt=<report id> purposes. Example: DynamicsNAV:////runreport?repo rt=50000 Server Allows you to switch name servers. DynamicsNAV://<ServerName>/ //RunPage?Page=<pageid> Example: Microsoft.Dynamics.Nav.Client.e xe DynamicsNAV://MyServer///Run Page?Page=22 Microsoft Official Training Materials for Microsoft Dynamics ® 5-13Your use of this content is subject to your current services agreement
  • 14. Report Design in Microsoft Dynamics® NAV 2009 Parameters Description Syntax Server Allows you to specify an DynamicsNAV://<ServerName> name optional port number in the <:Port>///RunPage?Page=<pagei optional range 1-65535. The default d> port number port is 7046. Example: Microsoft.Dynamics.Nav.Client.e xe DynamicsNAV://MyServer:1234 ///RunPage?Page=22 Service Allows you to specify a DynamicsNAV:///<Service>//Ru instance Service instance. You can nPage?Page=<pageid> find this value in the Example: CustomSettings.config file. Microsoft.Dynamics.Nav.Client.e xe DynamicsNAV:///DynamicsNAV //RunPage?Page=22 If you omit a parameter, such as Server or Service, do not remove the accompanying forward slash, because this 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. Run Hyperlinks In Microsoft Dynamics NAV you can run hyperlinks in different ways. You can run the report from the Run window, from a Command Prompt, from a shortcut or from a browser window. This is useful if, for example, you need to run a specific report for testing purposes or know the ID of a report that is run often. The following demonstrations illustrate how to run hyperlinks. Demonstration: Running a Report from the Run Window In the Classic client, users can create shortcuts to specific objects on the Windows Desktop. Mort starts to investigate whether this functionality also exists for the RoleTailored client. The first method was already used to test the reports in the previous chapters and labs. To run a report from the Run window, use the following steps: 1. On your machine, click Start and then Run. 2. In the Run dialog box, enter the following command: dynamicssnav:////runreport?report=<ReportID>.5-14 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 15. Chapter 5: Running Reports 3. Replace <ReportID> with the report ID that you want to use 111. 4. Click OK to run the report. The request options page, if any, will now be displayed in the RoleTailored client. FIGURE 5.8 THE ROLETAILORED CLIENT WITH THE REQUEST OPTIONS PAGE Demonstration: Running a Report from the Command Prompt To run a report from the Windows Desktop, you can create a shortcut to the report. To use a shortcut to run a report, follow these steps: 1. Click Start, Run. 2. In the Run window, enter cmd. 3. In the command prompt window, enter the following command:: "C:Program FilesMicrosoft Dynamics NAV60RoleTailored ClientMicrosoft.Dynamics.Nav.Client.exe" DynamicsNAV:////runreport?report=111. 4. Press Enter. Microsoft Official Training Materials for Microsoft Dynamics ® 5-15Your use of this content is subject to your current services agreement
  • 16. Report Design in Microsoft Dynamics® NAV 2009 Demonstration: Running a Report from a Shortcut To run a report from the Windows Desktop, you can create a shortcut to the report. To use a shortcut to run a report, follow these steps: 1. On your Windows Desktop, create a shortcut to the Microsoft.Dynamics.Nav.Client.exe. 2. Right-click the shortcut and select Properties. 3. In the Target field, add the hyperlink URL. The complete target will look like this: "C:Program FilesMicrosoft Dynamics NAV60RoleTailored ClientMicrosoft.Dynamics.Nav.Client.exe" DynamicsNAV:////runreport?report=111. 4. Click OK to close the Properties window. 5. Double-click the shortcut to run the report. Demonstration: Running a Report from a Browser Window The following steps show how to run a report from the browser window. 1. Open Microsoft Internet Explorer. 2. In the address bar; enter the following URL: DynamicsNav://localhost/DynamicsNAV/CRONUS International Ltd./runreport?report=111. 3. Press Enter to validate the URL. To run a report from the browser, the Microsoft Dynamics NAV 2009 RoleTailored client must be installed on the computer. Demonstration: Adding a Report Hyperlink to a Web Page Kevin has asked Tim, the IT manager, to conduct a small feasibility study for building a Customer Portal. One of the primary goals of this portal is to provide all outbound sales documents electronically, so the customer can download the documents. In addition, customers must be able to print specific reports themselves. Tim checks whether it is possible to launch a RoleTailored client report from a Web page. 1. From the Start menu, open Microsoft Visual Studio 2008. 2. Select File, New, Web Site. 3. In the New Web Site window, select the ASP.NET Web Site template. 4. In the top right corner, leave the .NET Framework 3.5 option.5-16 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 17. Chapter 5: Running Reports 5. In the Location field, enter the following path: C:Documents and Settings%USERNAME%My DocumentsVisual Studio 2008WebSitesHyperlinkTest (where %USERNAME% represents your Windows account). 6. In the Language field, select Visual Basic. 7. Click the OK button to create a new web site. 8. Click the Source button at the bottom of the window. 9. Place the cursor between the <div> and </div> tags. 10. Insert the following piece of code: <a href="DynamicsNav://localhost/DynamicsNAV/CRONUS International Ltd./runreport?report=111">The Customer Top 10 List</a> The result will look like this: FIGURE 5.9 THE WEB SITE PAGE IN SOURCE VIEW 11. Press F5 to run the Web site. 12. If the Debugging Not Enabled dialog box is displayed, select the Run without debugging option and click the OK button. 13. Click the hyperlink. Microsoft Official Training Materials for Microsoft Dynamics ® 5-17Your use of this content is subject to your current services agreement
  • 18. Report Design in Microsoft Dynamics® NAV 2009 Demonstration: Adding a Report Hyperlink to Favorites Now that Tim knows that links to a RoleTailored client report can be included on a Web page, he decides do to a little 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. 1. Right-click the The Customer Top 10 List link. 2. Select Add to Favorites. 3. In the Add a Favorite window, enter the following name for the report: Customer - Top 10 List. 4. Click the New Folder button. 5. In the Create a Folder window, enter the following Folder Name: DynamicsNAV Reports 6. In the Create In dropdown list, select Favorites. 7. 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 ADD A FAVORITE WINDOW 8. Click the Add button to close the Add a Favorite window. 9. In Internet Explorer, select Favorites, DynamicsNAV Reports. 10. Click the Customer Top 10 List link. The RoleTailored client will be launched 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. In Internet Explorer, select Favorites, DynamicsNAV Reports. 2. Right-click the Customer Top 10 List link.5-18 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 19. Chapter 5: Running Reports 3. Select Properties. 4. In the Customer Top 10 List Properties window, click the Web Document tab. FIGURE 5.11 CUSTOMER TOP 10 LIST PROPERTIES WINDOW Tim sees that the URL field contains the editable link to the report.Hyperlinks in E-mails Hyperlinks allow navigating between documents and offer instant access to the right information. This lesson describes to use hyperlinks in e-mail messages. When creating e-mails from C/AL code in the Classic client, you can use the Form.URL method and include it into the body of an e-mail. Whenever someone clicks the Link, the Classic Client is opened and the corresponding Form is shown. In Microsoft Dynamics NAV 2009, in the RoleTailored client, the Form.URL method is no longer supported. The RoleTailored client does not display forms; it uses Pages and Pages do not have an URL method. To create a link to a page, you have to create the URL as follows: dynamicsnav:////runpage?page=<Page No>&bookmark=<URL>. Microsoft Official Training Materials for Microsoft Dynamics ® 5-19 Your use of this content is subject to your current services agreement
  • 20. Report Design in Microsoft Dynamics® NAV 2009 Generating BookmarkURLs To get a BookmarkURL for a specific record, you need to use a RecordRef variable that points towards the specific record and use its RecordId property. The next challenge might be that your code is in a Codeunit and can sometimes be called from a form or a page. To make your code compatible with both environments, you can use the ISSERVICETIER function. If you call ISSERVICETIER from the Classic client, then the function returns FALSE. When called from the RoleTailored client, ISSERVICETIER returns TRUE. You can use the following piece of code to include bookmarks in the body of an e-mail: FIGURE 5.12 C/AL EDITOR WINDOW Notice the parameters of the FORMAT() function for the RecordRef variable. 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.Hyperlinks in a Report With the integration between Microsoft Dynamics NAV 2009 and SQL Reporting Services it is possible to create reports that provide dynamic data. Microsoft Dynamics NAV 2009 reports can among other things include images, graphics, interactive sorting, and toggle on data columns, and it can link to other data in the system. This lesson illustrates how to set up a report to include a link to the customer card page, so that when it is run in preview mode it can look up any existing customer directly from the report. Including this functionality the report no longer serves as a static, printed list, but becomes a dynamic list that can be used for direct drill-down into system data.5-20 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 21. Chapter 5: Running Reports Demonstration: Adding a Link in a Report When printing the Customer Top 10 List report, Michael notices that only the customer number and name are included in the list. To find the other customer information, Michael needs to open the Customer Card. He asks Mort whether it is not possible to include a link to the Customer Card in the report. Before he can include the link in Visual Studio, Mort needs to make a small change to the Classic report: he needs to add a variable and include the variable in a hidden textbox on a section. Add a Variable and Code to the Report 1. In the Classic client, click Tools, and then select Object Designer. 2. In Object Designer, click Report, and then locate the Customer - Top 10 List report by typing object ID 111. 3. Select the Customer - Top 10 List report and click the Design button. 4. In the Report Designer window, select the Customer data item, and then click View, C/AL Globals. 5. In the C/AL Globals window, on the Variables tab, add a new entry. 6. In the Name field, enter CustomerRecRef, and in the DataType field, select RecordRef. Close the C/AL Globals window. 7. In the Report Designer window with the Customer data item still selected, press F9 to open the C/AL Editor window. 8. On the OnPreDataItem() trigger, write the following line of code: CustomerRecRef.OPEN(18); 9. In the Report Designer window, change focus to the Integer data item. 10. In the C/AL Editor window, on the OnAfterGetRecord() trigger, enter the following line of code at the bottom of the trigger: CustomerRecRef.SETPOSITION(Customer.GETPOSITION); 11. Close the C/AL Editor window. Microsoft Official Training Materials for Microsoft Dynamics ® 5-21Your use of this content is subject to your current services agreement
  • 22. Report Design in Microsoft Dynamics® NAV 2009 Adding the Textbox Having created the variable CustomerRecRef, Mort must create a new textbox that will be used to get the value of the current customer represented in the dataset in Visual Studio once the layout is opened there. The textbox is not going to be visible on the report when it is run, but is only used for transformation purposes. The following steps illustrate how to add the textbox to the report. 1. With the Customer - Top 10 List report open in Report Designer, click View, and then select Sections. 2. In the Section Designer window, locate the BarText textbox and resize it to make room for a new small textbox. 3. Click View, and then select Toolbox. 4. From Toolbox, click Textbox and then click the report design to place it next to the BarText textbox. 5. Right-click the new Textbox and select Properties. 6. In the Properties window, on the SourceExpr property, enter the following expression: FORMAT(CustomerRecRef.RECORDID,0,10) 7. Close the Properties window. 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. 8. In the Properties window, set the Visible property to No. 9. Save and compile the report. Once the variable and the textbox are created using Microsoft Dynamics Report Designer, Mort can open the layout of the report and further 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. Notice that the newly created textbox is now part of the dataset in Visual Studio under Data Sources and its value is being referenced in the link you are adding. 1. In the Classic client, with the Customer - Top 10 List report open in Report Designer, click View, and then select Layout. 2. In Visual Studio, in the Body section of the report, locate the textbox Customer__No__. The value of the textbox is =Fields!Customer__No__.Value. 3. Right-click the textbox and select Properties.5-22 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 23. Chapter 5: Running Reports 4. In the Properties window, go to the Navigation tab. 5. Select the Jump to URL option and enter the following expression in the field: ="dynamicsnav:////runpage?page=21&mode=edit&bookmark="+Fiel ds!FORMAT_CustomerRecRef_RECORDID_0_10_.Value The result will look like this: FIGURE 5.13 TEXTBOX PROPERTIES WINDOW Notice that the mode parameter is used. This will allow the user to edit the customer page. 6. Click OK to close the window. 7. Save the report in Visual Studio and return to the Classic client. 8. Save and compile the report in the Classic client. In the Classic client, 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. 1. Select Tools, and then click Compile to compile the report. 2. On the Windows taskbar, click Start and then click Run. Microsoft Official Training Materials for Microsoft Dynamics ® 5-23Your use of this content is subject to your current services agreement
  • 24. Report Design in Microsoft Dynamics® NAV 2009 3. In the Run window, enter the following string: dynamicsnav:////runreport?report=111 and click OK. 4. Click Preview to view the report. The report lists the top 10 list of customers. FIGURE 5.14 CUSTOMER TOP 10 REPORT PREVIEW If resting on the customer number you will get a link to open the specific customer on a separate customer card making it possible to drill down into the customers data. Microsoft Dynamics NAV 2009 Service Pack 1 will offer Drill Through functionality, so you can create links to other reports.Interesting Links This section contains a non-exhaustive list of hyperlinks and resources to useful information regarding Microsoft Dynamics NAV 2009 and reporting. The Microsoft Dynamics NAV Reporting Blog This blog is written by members of the Microsoft Dynamics NAV Reporting Team and dedicated entirely to client-side reporting in Microsoft Dynamics NAV 2009.5-24 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 25. Chapter 5: Running Reports The idea with this blog is to collect and share information and tips and tricks for the new reporting environment for Microsoft Dynamics NAV. Also this blog offers the ability to provide feedback directly to the Microsoft Dynamics Reporting Team. http://blogs.msdn.com/nav-reporting The Microsoft Dynamics NAV Developer Blog This site is written by engineers in the Microsoft Dynamics NAV team worldwide. The blog contains technical articles about Microsoft Dynamics NAV 2009 in general. http://blogs.msdn.com/nav_developer/default.aspx The Microsoft Dynamics NAV Sustained Engineering Team Blog The Microsoft Dynamics NAV Sustained Engineering Team Blog is mostly written by members of the Microsoft Dynamics NAV Sustained Engineering team. http://blogs.msdn.com/microsoft_dynamics_nav_sustained_engineering/ 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://blogs.msdn.com/nav/default.aspx Microsoft Dynamics Developer Center Microsoft Developer Network (MSDN) Developer Centers and Resource Centers pull together content and resources around 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 gives access to all kinds of development resources for each of the 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. Furthermore it contains links to newsgroups, communities and (team) blogs. http://msdn.microsoft.com/en-us/dynamics/default.aspx Microsoft Official Training Materials for Microsoft Dynamics ® 5-25Your use of this content is subject to your current services agreement
  • 26. Report Design in Microsoft Dynamics® NAV 2009 Microsoft SQL Server Development Center The Microsoft SQL Server Development Center contains all kinds of resources and information regarding development in Microsoft SQL Server®. http://msdn.microsoft.com/en-us/sqlserver/default.aspx 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://msdn.microsoft.com/en-us/sqlserver/cc511478.aspx Microsoft Visual Studio Following is the home page of the Microsoft Visual Studio product family. http://www.microsoft.com/visualstudio/ Microsoft Visual Studio Express Editions This site contains resources for the Microsoft Visual Studio Express Editions. The page includes software downloads, samples and resources as well as information about Frequently Asked Questions (FAQ), system requirements, help resources, installation topics, and forums. http://www.microsoft.com/express/ Creating and Consuming a Codeunit Web Service This walkthrough provides an overview of how to create and consume a simple Web service with Microsoft Dynamics NAV. http://msdn.microsoft.com/en-us/library/dd339004.aspx Microsoft Dynamics NAV 2009 Launch Portal The Launch Portal references tools, training, and content you can use to kick start your Microsoft Dynamics NAV 2009 readiness. This material supplements the communications and processes that are provided by your local Microsoft country or regional organization. A PartnerSource login is required. https://mbs.microsoft.com/partnersource/marketing/campaigns/prospect/launchm dnav.htm5-26 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 27. Chapter 5: Running Reports Microsoft Dynamics NAV 2009 Developer and IT Pro Help The Microsoft Dynamics NAV 2009 Developer and IT Pro Help provides information about developing for, installing, and managing Microsoft Dynamics NAV 2009. 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 this page: http://go.microsoft.com/fwlink/?linkid=126282 User Experience Guidelines for Microsoft Dynamics NAV 2009 The Microsoft Dynamics NAV 2009 User Experience Guidelines (or “UX Guide” for short) is a tool to assist 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 violations. http://www.microsoft.com/downloads/details.aspx?FamilyID=8B5AB93F-480B- 4C14-868A-98F6B9BC3E86&displaylang=en Microsoft Dynamics NAV Developer Documentation This page contains links to several technical articles related to development in Microsoft Dynamics NAV. http://msdn.microsoft.com/en-us/library/dd355683.aspx The Microsoft Dynamics NAV Technical Community This site offers a wide variety of tools to help you connect and collaborate with other Microsoft Dynamics NAV users, developers and implementers. https://community.dynamics.com/nav/home.aspx 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://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=2 a20c7af-52e8-4882-bd24-9479b3c7517d Microsoft Official Training Materials for Microsoft Dynamics ® 5-27Your use of this content is subject to your current services agreement
  • 28. Report Design in Microsoft Dynamics® NAV 2009 Report Design Tips and Tricks This white paper covers best practices on report design and helps you avoid common mistakes when choosing a report layout and output format. Take advantage of existing product features to achieve the results you want. The paper includes report and code examples that implement functionality that is frequently requested (32 printed pages). http://msdn.microsoft.com/en-us/library/bb395166.aspx Microsoft Most Valuable Porfessional (MVP) and Other Sites www.mibuso.com (http://www.mibuso.com) (MVP Site) www.waldo.be (http://www.waldo.be) (MVP Site) Dynamics User Group (http://dynamicsuser.net/) (Dynamics NAV Online User Community) http://www.dynamicsblog.at/ (Austrian Dynamics blog) http://blogs.msdn.com/german_nav_developer/ (German NAV Developers blog) http://www.plataan.be (Microsoft CPLS)5-28 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 29. Chapter 5: Running ReportsLab 5.1 - Add a Report to the RoleTailored Client In this lab you will add one of the reports built in previous chapters to the RoleTailored client interface. Scenario Prakash wants his Resource - Utilization (Chart) Report (report 123456706) to be available from the Role Center menu, so 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. In addition, he wants it to be accessible from the Resources page in the Departments section (under the Reports and Analysis category). Challenge Yourself! Add report 123456706, created in Lab 4.2, to the Role Center menu for Prakash and the other project managers. Furthermore, create a new MenuSuite object to make the report available under the Reports and Analysis category in the Resources section of the Departments page. Need a Little Help? The following steps show how to add the report to the RoleTailored client: 1. Add the Report to the Job Project Manager RC Page. 2. Create a New MenuSuite Object. 3. Change the MenuSuite Object to Add the Report to the Departments Section 4. Create a New Shortcut for the RoleTailored client. 5. Change the New Shortcut for the RoleTailored client. 6. Start the RoleTailored Client with the Project Manager profile (in Configuration Mode). Step by Step Add the Report to the Job Project Manager RC Page 1. In the Microsoft Dynamics NAV Classic client, open Object Designer. 2. Click the Page button. 3. Select page 9015, Job Project Manager RC. 4. Click Design to open the page in Page Designer. 5. Select an empty line in the designer. Click View, and then Actions to open Action Designer. 6. Scroll down to the Action that has Jobs per Item as its Caption. 7. Click the Separator button to insert a separator. Microsoft Official Training Materials for Microsoft Dynamics ® 5-29 Your use of this content is subject to your current services agreement
  • 30. Report Design in Microsoft Dynamics® NAV 2009 8. Scroll down to the ActionContainer that has HomeItems as its Subtype. 9. Press F3 to insert a new empty line (or select Edit, New). 10. On the new line, in the Caption field, enter a name for the action: Resource - Utilization (Chart). 11. In the Type field, select Action. 12. Click View, and then Properties to open the Properties window for the new action. 13. In the Value field of the RunObject property, click the drop-down arrow and select report 123456706 in the Object List window. 14. Compile and save the page. 15. Open the RoleTailored client and then open the Role Center page. Create a new MenuSuite Object 1. In the Microsoft Dynamics NAV Classic client, open Object Designer. 2. Click the MenuSuite button. 3. Click the New button to open the Design Level window. 4. In the Design for field, select RoleTailored Client. 5. In the listbox, select the Dept - Partner level. 6. Save the MenuSuite object. Change the MenuSuite Object to Add the Report to the Departments Section 1. In the Navigation Pane Designer, select the Resource Planning menu. 2. Expand the Reports group. 3. Right-click the last report in the Reports group (Resource - Price List) and select Create Item. 4. In the Create Item window, select Report in the Object Type field. 5. In the Object ID field, click the dropdown arrow and select report 123456706 in the Object List window. 6. In the Caption field, change the caption to Resource - Utilization (Chart). 7. In the Department Category field, select Reports and Analysis. 8. Click OK to close the Create Item window. 9. Compile and save the MenuSuite.5-30 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 31. Chapter 5: Running Reports Create a New Shortcut for the RoleTailored Client 1. Right-click the Windows Desktop and select New > Shortcut. 2. In the Create Shortcut window, click the Browse button. 3. In the Browse for Folder window, browse to the following path and application: C:Program FilesMicrosoft Dynamics NAV60RoleTailored ClientMicrosoft.Dynamics.Nav.Client.exe 4. Click the OK button to close the Browse for Folder window. 5. In the Create Shortcut window, click the Next button. 6. Enter the following name for the shortcut: Project Manager Profile. 7. Click the Finish button. Change the New Shortcut for the RoleTailored Client 1. Right-click the newly created shortcut. 2. Select Properties. 3. Change the Target field to: "C:Program FilesMicrosoft Dynamics NAV60RoleTailored ClientMicrosoft.Dynamics.Nav.Client.exe" -configure - profile:"Project Manager" 4. Click the Apply button. 5. Click the OK button. Microsoft Official Training Materials for Microsoft Dynamics ® 5-31Your use of this content is subject to your current services agreement
  • 32. Report Design in Microsoft Dynamics® NAV 2009 Start the RoleTailored Client with the Project Manager Profile (in Configuration Mode) 1. On the Windows Desktop, double-click the Project Manager Profile icon. 2. On the Role Center page, click the Reports menu. FIGURE 5.15 ROLE CENTER PAGE WINDOW 3. Click the Departments menu. 4. 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-32 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 33. Chapter 5: Running ReportsLab 5.2 - Call a Report from a Web Service In this lab, you will build a small codeunit and expose it as a Web service. Although this course is not a Web development course, you will see how to build a small Web application that consumes the Web service. This lab is for educational purposes only and does not focus on defining the right application security. Therefore, it is highly recommended not to implement the lab "as is" in a live production environment. Scenario While she is talking to customers, Susan regularly gets requests from customers who have questions about sales invoices and shipments. Currently, Susan carefully takes all the details and sends the case to the responsible representative, who handles it. At the same time, Rebecca gets 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 they can add it to the case or send it to the customers. Mort views this as an excellent opportunity to realize one of his dreams: a self- serving customer portal. Challenge Yourself! Build a Web service that can check whether a specific posted sales document (invoice, credit memorandum and shipment) exists and that can print the specific document as a PDF. Build a small Web application that consumes this Web service; the user needs to specify a document type and a document number and click a Search button. When a wrong document number is entered, a small error message needs to appear to notify the user. Need a Little Help? 1. Create a New Codeunit. 2. Add Global Variables to the Codeunit. 3. Add the CheckInvoiceNo function to the Codeunit. 4. Add code to the CheckDocNo function. 5. Add the GenerateReport function to the Codeunit. 6. Add code to the GenerateReport function. 7. Expose the Codeunit as a Web Service. 8. Create a New Web site. 9. Add Controls to the Web site. 10. Add the Web Service Reference. Microsoft Official Training Materials for Microsoft Dynamics ® 5-33 Your use of this content is subject to your current services agreement
  • 34. Report Design in Microsoft Dynamics® NAV 2009 11. Add Code to Consume the Web Service. 12. Run the Web Application. Step by Step Create a New Codeunit 1. In the Microsoft Dynamics NAV Classic client, open Object Designer. 2. Click the Codeunit button. 3. Click the New button 4. Select File, Save As. 5. In the ID field, enter 123456701. 6. In the Name field, enter Get Sales Document WS. 7. Check the Compiled field. 8. Click OK. Add Global Variables to the Codeunit 1. Select View, C/AL Globals to open the C/AL Globals window. 2. On the Variables tab, select the first (empty) line. 3. In the Name field, enter FileName. 4. In the DataType field, select Text. 5. In the Length field, enter 250. 6. Select the next line. 7. In the Name field, enter SalesInvHdr. 8. In the DataType field, select Record. 9. In the Subtype field, click the button and select the Sales Invoice Header table from the Object List window. 10. Select the next line. 11. In the Name field, enter SalesCMHdr. 12. In the DataType field, select Record. 13. In the Subtype field, click the button and select the Sales Cr.Memo Header table from the Object List window. 14. Select the next line. 15. In the Name field, enter SalesShptHdr.5-34 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 35. Chapter 5: Running Reports 16. In the DataType field, select Record. 17. In the Subtype field, click the button and select the Sales Shipment Header table from the Object List window. FIGURE 5.16 THE C/AL GLOBALS WINDOW 18. Select File, Save to save and compile the codeunit. Add the CheckDocNo function to the Codeunit 1. In the C/AL Globals window, click the Functions tab. 2. On the first empty line, enter CheckDocNo. 3. Place the cursor on the line containing the CheckDocNo function and click the Locals button to open the C/AL Locals window. 4. On the Parameters tab, select the first empty line. 5. In the Name field, enter DocType. 6. In the DataType field, select Integer. 7. Select the next line. 8. In the Name field, enter DocNo. 9. In the DataType field, select Code. 10. In the Length field, enter 20. 11. Click the Return Value tab. 12. In the Return Type field, select Integer. 13. Close the C/AL Locals window. Add the GenerateReport Function to the Codeunit 1. In the C/AL Globals window, click the Functions tab. 2. On the first empty line, enter GenerateReport. 3. Place the cursor on the line containing the GenerateReport function and click the Locals button to open the C/AL Locals window. 4. On the Parameters tab, select the first empty line. Microsoft Official Training Materials for Microsoft Dynamics ® 5-35Your use of this content is subject to your current services agreement
  • 36. Report Design in Microsoft Dynamics® NAV 2009 5. In the Name field, enter DocType. 6. In the DataType field, select Integer. 7. Select the next line. 8. In the Name field, enter DocNo. 9. In the DataType field, select Code. 10. In the Length field, enter 20. 11. Click the Return Value tab. 12. In the Return Type field, select Text. 13. In the Length field, enter 250. 14. Close the C/AL Locals window. 15. Close the C/AL Globals window to return to the C/AL Editor. Add Code to the CheckDocNo Function 1. In the C/AL Editor, enter the following code in the CheckDocNo() function trigger: 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 EXIT(1) END ELSE EXIT(0); END; END;5-36 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 37. Chapter 5: Running Reports 2. Select File, Save to compile the codeunit. The function trigger will look like this: FIGURE 5.17 THE CHECKDOCNO FUNCTION Add Code to the GenerateReport Function 1. In the C/AL Editor, enter the following code in the GenerateReport() function trigger. // Determine the PDF File Name FileName := C:; 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; 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); Microsoft Official Training Materials for Microsoft Dynamics ® 5-37Your use of this content is subject to your current services agreement
  • 38. Report Design in Microsoft Dynamics® NAV 2009 2. Select File, Save to compile the codeunit. The function trigger will look like this: FIGURE 5.18 THE GENERATEREPORT FUNCTION 3. Close the C/AL Editor. 4. Close Object Designer. Expose the Codeunit as a Web Service 1. In the Navigation Pane, select Administration, IT Administration, General Setup, Web Services. 2. In the Web Services window, select a blank line. 3. In the Object Type field, select Codeunit. 4. In the Object ID field, enter 123456701.5-38 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 39. Chapter 5: Running Reports 5. In the Service Name field, enter Get_Sls_Doc. 6. Place a checkmark in the Published field. The codeunit will now be exposed as a Web service. FIGURE 5.19 THE WEB SERVICES WINDOW Test the Availability of the New Web Service 1. Open Internet Explorer. 2. In the browser bar, enter the following URL: http://localhost:7047/DynamicsNAV/WS/services. FIGURE 5.20 WINDOWS INTERNET EXPLORER WINDOW Microsoft Official Training Materials for Microsoft Dynamics ® 5-39Your use of this content is subject to your current services agreement
  • 40. Report Design in Microsoft Dynamics® NAV 2009 The newly published Web service appears in the list with the Service Name specified in the Web Services window. If the list of Web services does not appear, check whether the service "Microsoft Dynamics NAV Business Web Services" is started. Create a New Web Site 1. Select Start, All Programs, Microsoft Visual Studio 2008, Microsoft Visual Studio 2008. 2. Select File, New, Web Site. 3. In the New Web Site window, select the ASP.NET Web Site template. 4. In the top right corner, leave the .NET Framework 3.5 option. 5. In the Location field, enter the following path: C:Documents and Settings%USERNAME%My DocumentsVisual Studio 2008WebSitesLab52 (where %USERNAME% represents your Windows account). 6. In the Language field, select Visual Basic. 7. Click the OK button to create the new web site. The result should look similar to this: FIGURE 5.21 A NEW BLANK WEB SITE5-40 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 41. Chapter 5: Running Reports The ASP Editor window in the middle displays a tab for the default page of the Web site, which is called default.aspx. Notice the Design, Split and View buttons at the bottom of the ASP Editor window. 8. Click the Design button to switch to the design view. Add Controls to the Web Site 1. In the Toolbox window, select the RadioButtonList control. 2. Drag it inside the <div> element on the default.aspx page. The control remains selected on the design surface. 3. Press the right arrow to place the cursor next to the control. 4. Press Enter. 5. In the Toolbox window, select the Textbox control. 6. Drag it inside the <div> element, under the RadioButtonList. 7. With the Textbox control selected, press the spacebar two times to insert two blank spaces after the control. 8. In the Toolbox window, select the Label control. 9. Drag it inside the <div> element, right next to the Textbox. 10. With the Label control selected, press the right arrow key to place the cursor next to the control. 11. Press Enter. Microsoft Official Training Materials for Microsoft Dynamics ® 5-41Your use of this content is subject to your current services agreement
  • 42. Report Design in Microsoft Dynamics® NAV 2009 12. In the Toolbox window, select the Button control. 13. Drag it inside the <div> element, under the Textbox control. The result will look like this. FIGURE 5.22 THE NEW WEB SITE WITH CONTROLS Design the Controls on the Web Site 1. Select the Textbox control. 2. In the Properties window, set the (ID) property to txtDocNo. 3. Expand the Font property collection. 4. Set the Name property to Verdana. 5. Set the Size property to Small. 6. Select the Label control. 7. In the Properties window, set the (ID) property to lblErrorMsg. 8. Set the ForeColor property to Red. 9. Set the Text property to Error Message. 10. Set the Visible property to False. 11. Expand the Font property collection. 12. Set the Bold property to True. 13. Set the Name property to Verdana. 14. Set the Size property to Small. 15. Select the Button control. 16. In the Properties window, set the (ID) property to cmdSearch. 17. Set the Text property to Search. 18. Expand the Font property collection. 19. Set the Name property to Verdana.5-42 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 43. Chapter 5: Running Reports 20. Set the Size property to Small. 21. Select the RadioButtonList control. 22. In the Properties window, set the (ID) property to rblDocType. 23. Expand the Font property collection. 24. Set the Name property to Verdana. 25. Set the Size property to Small. 26. Clik the > button on the top right corner of the RadioButtonList control. 27. In the RadioButtonList Tasks pane, select Edit Items. 28. In the ListItem Collection Editor window, click the Add button. 29. In the ListItem properties window, set the Text property to Posted Invoice. 30. Change the Value property to 112. 31. Set the Selected property to True. 32. Click the Add button. (The newly added item will appear in the Members list.) 33. In the ListItem properties window, set the Text property to Posted Credit Memo. 34. Change the Value property to 114. 35. Click the Add button. (The newly added item will appear in the Members list.) 36. In the ListItem properties window, set the Text property to Posted Shipment. 37. Change the Value property to 110. 38. Click the OK button to close the ListItem Collection Editor window. 39. Select File, Save to save the file. Microsoft Official Training Materials for Microsoft Dynamics ® 5-43Your use of this content is subject to your current services agreement
  • 44. Report Design in Microsoft Dynamics® NAV 2009 The result will look similar to this: FIGURE 5.23 WEB SERVICE WINDOW Add the Web Service Reference As consuming a Web Service is not in the scope for this training, it is recommended to check the online help of Microsoft Dynamics NAV 2009 or the MSDN Web site at http://msdn.microsoft.com/en-us/library/dd339004.aspx. 1. In the Solution Explorer window, right-click the Lab52 project and select Add Service Reference. 2. In the Add Service Reference window, click the Advanced button. 3. In the Service Reference Settings window, click the Add Web Reference button to open the Add Web Reference window. 4. In the URL field, enter http://localhost:7047/DynamicsNAV/WS/services.5-44 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 45. Chapter 5: Running Reports 5. Click the Go button. 6. In the left listbox, Discovery Page, click the View Service link for the Get_Sls_Doc service. FIGURE 5.24 THE WEB SERVICE DESCRIPTION 7. Click the Add Reference button to add a reference to the web service. Add Code to Consume the Web Service 1. Click the Default.aspx tab. 2. Double-click the Search button in Design view. 3. On the Default.aspx.vb tab, enter the following piece of code in the cmdSearch_Click procedure. Dim service As localhost.Get_Sls_Doc = New localhost.Get_Sls_Doc Dim pdfFileName As String Dim DocCheck As Integer service.UseDefaultCredentials = True service.Url ="http://localhost:7047/DynamicsNAV/WS/CRONUS_International _Ltd/Codeunit/Get_Sls_Doc" DocCheck = service.CheckDocNo(rblDocType.SelectedValue, txtDocNo.Text) Microsoft Official Training Materials for Microsoft Dynamics ® 5-45Your use of this content is subject to your current services agreement
  • 46. Report Design in Microsoft Dynamics® NAV 2009 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/DynamicsNAV/WS/CRONUS_International _Ltd/Codeunit/Get_Sls_Doc" Response.ContentType ="application/pdf" pdfFileName = service.GenerateReport(rblDocType.SelectedValue, txtDocNo.Text) Response.TransmitFile(pdfFileName) End If The result will look like this: FIGURE 5.25 THE CODE TO CONSUME THE WEB SERVICES 4. Click File, Save All to save the modified files. Run the Web Application 1. On the Default.aspx page, press F5. 2. If the Debugging Not Enabled dialog box is displayed, select the Run without debugging option and click the OK button.5-46 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 47. Chapter 5: Running Reports The result will look like this: FIGURE 5.26 WEB SERVICE WINDOW Test the Web Application To test the application, use this scenario: 1. Select the Posted Shipment option. Microsoft Official Training Materials for Microsoft Dynamics ® 5-47Your use of this content is subject to your current services agreement
  • 48. Report Design in Microsoft Dynamics® NAV 2009 2. In the textbox, enter 103007. 3. Click the Search button. FIGURE 5.27 WEB SERVICE WINDOW5-48 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 49. Chapter 5: Running Reports 1. Select the Posted Invoice option. 2. In the textbox, enter 103007. 3. Click the Search button. FIGURE 5.28 SALES INVOICE REPORTSummary This chapter described how to create and run hyperlinks to reports for the RoleTailored client. It also explained how to create and use a Microsoft Dynamics NAV Web service that prints a report. Microsoft Official Training Materials for Microsoft Dynamics ® 5-49 Your use of this content is subject to your current services agreement
  • 50. Report Design in Microsoft Dynamics® NAV 2009Test Your Knowledge Test your knowledge with the following questions. 1. Which functionalities are available from the ReportViewer Control Toolbar? (Select all that apply) ( ) 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 clients equivalent for the Navigation Pane in the Classic Client? ( ) The Role Center Pages ( ) The Activities Pages ( ) The Action Pane ( ) The Departments Page 5. What is true about MenuSuites for the RoleTailored Client? (Select all that apply) ( ) 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-50 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement
  • 51. Chapter 5: Running ReportsQuick Interaction: Lessons Learned Take a moment and write down three Key Points you have learned from this chapter 1. 2. 3. Microsoft Official Training Materials for Microsoft Dynamics ® 5-51 Your use of this content is subject to your current services agreement
  • 52. Report Design in Microsoft Dynamics® NAV 2009Solutions Test Your Knowledge 1. Which functionalities are available from the ReportViewer Control Toolbar? (Select all that apply) (√) 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 clients equivalent for the Navigation Pane in the Classic Client? ( ) The Role Center Pages ( ) The Activities Pages ( ) The Action Pane (•) The Departments Page 5. What is true about MenuSuites for the RoleTailored Client? (Select all that apply) (√) 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-52 Microsoft Official Training Materials for Microsoft Dynamics ® Your use of this content is subject to your current services agreement

×