How to: Redesign the Number of Copies Option

[This topic is prerelease documentation and is subject to change in future releases. Blank topics are included as placeholders. There may be some display and formatting issues until the look and feel is finalized.]

For document type reports, often the request page 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 development environment, on the Tools menu, choose Object Designer.

  2. In Object Designer, choose Report, select the report that you want to modify to print multiple copies, and then choose Design.

  3. On the View menu, choose 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 Dataset Designer, select the CopyLoop data item.

  6. On the View menu, choose 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 ISSERVICETIER THEN    // Added line
        OutputNo += 1;       // Added line
    END;                     // Existing line
    
  9. On the View menu, choose 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, choose Save.

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

To group data based on copy number

  1. In the development environment,, on the View menu, choose Layout.

  2. In Microsoft Visual Studio, in the report.rdlc file, right-click the row that you want to group on, and then choose 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, choose 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 Report Dataset Designer and Visual Studio Report Designer.