How to: Redesign the Number of Copies Option

Microsoft Dynamics Nav 2009

For document type reports, often the request form displays an option for number of copies to print. In a client report definition (RDLC) report layout, a copy is the same as a new document that must start on a new page. You must add code to set and update the copy number, group the data based on the copy number, and then specify a page break at the end of the group.

Before you begin this procedure, you must create the RDLC layout suggestion for the report. For more information, see How to: Create a Layout Suggestion.

To add code to the report for the number of copies

  1. In the Classic client, on the Tools menu, click Object Designer.

  2. In Object Designer, click Report, select the report that you want to modify to print multiple copies, 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 the following variable.

    Name DataType

    OutputNo

    Integer

  5. In Report Designer, select the CopyLoop data item.

  6. On the View menu, click C/AL Code.

  7. In the C/AL Editor, add the following code to the OnPreDataItem trigger to create and initialize the new page number variable.

    IF ISSERVICETIER THEN
      OutputNo := 1;
    
  8. In the C/AL Editor, modify the existing code in the OnAfterGetRecord trigger to increment the page number variable.

    IF Number > 1 THEN BEGIN // Existing line
      CopyText := Text003;   // Existing line
      IF SERVICETIER THEN    // Added line
        OutputNo += 1;       // Added line
    END;                     // Existing line
    
  9. On the View menu, click Sections.

  10. In the PageLoop Header section, add a hidden text box whose SourceExpr is the page number variable. For example, in report 206, there is a hidden text box for the OutputNo variable. For more information, see How to: Add and Identify Hidden Fields.

  11. On the File menu, click Save.

  12. In the Save window, select the Compiled check box, and then click OK.

To group data based on copy number

  1. In the Classic client, on the View menu, click Layout.

  2. In Microsoft Visual Studio, in the report.rdlc file, right-click the row that you want to group on, and then click Edit Group.

  3. In the Grouping and Sorting Properties window, on the General tab, under Group on, select the next blank line to add a grouping, and then select =Fields!OutputNo.Value from the drop-down list.

  4. In the Grouping and Sorting Properties window, click the Sorting tab.

  5. Select a blank line, and then select =Fields!OutputNo.Value from the drop-down list.

  6. Save and compile the report. For more information, see How to: Integrate Classic Client Report Designer and Visual Studio Report Designer.

Community Additions

ADD
Show: