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
-
In the Classic client, on the Tools menu, click Object Designer.
-
In Object Designer, click Report, select the report that you want to modify to print multiple copies, and then click Design.
-
On the View menu, click C/AL Globals.
-
In the C/AL Globals window, on the Variables tab, add the following variable.
Name DataType OutputNo
Integer
-
In Report Designer, select the CopyLoop data item.
-
On the View menu, click C/AL Code.
-
In the C/AL Editor, add the following code to the OnPreDataItem trigger to create and initialize the new page number variable.
Copy Code IF ISSERVICETIER THEN OutputNo := 1;
-
In the C/AL Editor, modify the existing code in the OnAfterGetRecord trigger to increment the page number variable.
Copy Code IF Number > 1 THEN BEGIN // Existing line CopyText := Text003; // Existing line IF SERVICETIER THEN // Added line OutputNo += 1; // Added line END; // Existing line
-
On the View menu, click Sections.
-
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.
-
On the File menu, click Save.
-
In the Save window, select the Compiled check box, and then click OK.
To group data based on copy number
-
In the Classic client, on the View menu, click Layout.
-
In Microsoft Visual Studio, in the report.rdlc file, right-click the row that you want to group on, and then click Edit Group.
-
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.
-
In the Grouping and Sorting Properties window, click the Sorting tab.
-
Select a blank line, and then select =Fields!OutputNo.Value from the drop-down list.
-
Save and compile the report. For more information, see How to: Integrate Classic Client Report Designer and Visual Studio Report Designer.