Saturday, January 7, 2017

How to Print Microsoft Dynamics NAV 2013 R2 RDLC Report Page Footer on Last Page Only

As we are all know there were two properties in NAV 2009 to print footer at bottom and on last page of report using PrintOnEveryPage and PlaceInBottom properties, but in RDLC report there are no such properties to achieve this.
In RDLC report we can use page footer to print footer at bottom of a report, but it prints on every page, because of these below two properties:
    1.  “Print on first page”: It prints page footer on every page except last page.
    2.  “Print on last page”: It prints page footer on every page except first page.
As I explained in above points we can use page footer to print footer at bottom of a page but it prints on every page, except very first or last page. So what is the way to print page footer at an end of a report? Here I explain how to achieve this using a simple method.
If we want to hide a text box from all pages except last page, set an expression to visibility property of the text box. The expression is to hide the text box in all pages except last page, therefore use the built-in fields to achieve this.
Expression and its syntax explained below:
=IIF(Expression, Yes, No);
   1.  Expression (1st parameter) = it’s a condition for hide, hide if current page is not last page (If current page is not equal to last page). IIF means “If and only if”.
   2.  Yes/True (2nd Parameter) = Hide if condition is true.
   3.  No/False (3rd Parameter) =Show if condition is true.
Here we are writing expression for not to hide if current page is equal to last page so the expression looks like this:
 ”=IIF(CurrPage=LastPage, Don’t hide, Else hide)”, So the expression is “=IIF(Globals!PageNumber=Globals!TotalPages, false, true)”.
What if two or more text boxes to hide? In this scenario place all text boxes inside a rectangle control and apply this visibility condition to the rectangle instead each text boxes.
Please have a look at below screenshot shows how to write above expression or how to hide text if current page is not the last one.


Figure 1: Shows how to hide text if current page is not the last.
If you wish to discuss regarding this RDLC Report Design blog, please feel free to drop me an email to dileepakb08@gmail.com

How to print Header and Details (Lines) in different pages of a RDLC Report in NAV


We usually print header and details section of a document on same page, what if we want to print on different pages? And how to do this?
We can print header and details section of a document in different pages easily. To achieve this we have to place two different table controls, where one table control refers to header and another refers to details (lines), in a list control with a few properties change of these controls such as grouping, and page breaks, for example.
In this blog I’m printing sales header in first table and sales lines another, where each table data should print in different pages. To do this, we must first group the data into a single entity for each document using List control and after group each table controls, header table with header grouping and line table with details grouping, whereas sales header table control prints sales header information and sales line table control prints list of sales lines, and to print sales header and lines in separate with different pages, by setting up page break properties of each group.
Step by step:
1.   Place a List control on report body section. List control is used to list entries one after another. As we place two table controls (Header and Lines) it list entries from each tables such as Header and its lines as one after another in different pages.
2.   Place two table controls inside the List control, one after another vertically, for example, whichever order you wish, as shown below.

Screenshot 1: Shows Table controls inside List control.
3.   We group sales document based on sales document number, hence we must group data in the list control as shown below.

Screenshot 2: Shows grouping List control.

Screenshot 3: Shows grouping with sales document number.
4.   Group sales header table with sales document number. Follow the same steps done for the list control.
5.   Apply parent grouping to sales line table as shown below. In sales line table we group sales lines based on sales document number because we need to print list of sale lines for each header.

Screenshot 4: Shows parent grouping of sales line table.

Screenshot 5: Shows how to add group header with parent grouping to sales line table.

Screenshot 6: Shows how sales lines table looks after grouping.
You can delete columns which are not necessary in the table.
6.   After grouping has been done, you should apply page break to both table controls, as both inserts a new page when they finishes printing entries for each document, to print both sales header and details in different pages. Select the group in each table control and apply page break as shown below. To apply page breaks, select the group and open properties window of it as shown below.

Screenshot 7: Shows how to select the group to which page break applies.

Screenshot 8: Shows properties window of the group to apply page breaks.
Note: Reset page number for sales line table only as it indicates the end of a document and restart the page number with new document.
7.   Add fields and parameters you wish to print in the report, as shown below.

Screenshot 9: Shows after grouping and fields.
8.    Report output: First screenshot shows sales header and second shows relevant sales lines of the document shows in first screenshot.

Screenshot 10: Shows Header in first page.

Screenshot 11: Sales Lines in second page.
If you wish to discuss regarding this RDLC Report Design blog, please feel free to drop me an email to dileepakb08@gmail.com.