In Headers and Footers in RDL Layout we cannot just add fields from the dataset. Instead, we must add the field to the Body of the report (but hide it), and then use the ReportItems! collection in the header to refer to the field in the Body.
This method is used on almost every report in NAV. But some times the field is hidden too well and is not shown in the header when the report is printed.
Further details about ReportItems! here:
Print versus preview
The report viewer renders the data differently depending on whether it prints or previews. Preview is optimised for an on-screen user experience, and interactive features like interactive sorting, document map, hyperlinks etc are available. Print is optimised to fit the report to a piece of paper.
The two renderings render ReportItems! in different ways. In preview we use “soft pagebreak” while in print we use “Hard pagebreak”. With hard pagebreak, ReportItems! will only have a value if the field that it refers to is on the current page. While with soft pagebreak, it doesn’t matter so much where in the report a field is.
Further details about Rendering here:
Understanding Rendering Behaviors
Another different behaviour has to do with how we hide the field in the body. This behaviour is not very logical, and it may change in future versions. But we found that for the current versions of RDL and report viewer, there is one small but important thing to be aware of when hiding the field in the Body:
If you hide the whole column or the whole row where a field is, then this field will not be visible via ReportItems! in Print. It will still show in preview. To avoid this, do not hide whole table rows or columns, but make sure to hide only individual field(s).
No need to waste paper
Finally, to see how your report will look when printing, you don’t have to actually print it out. From the preview, just select “Print layout”:
Then the preview will change its rendering to Print. Unless the report uses CurrReport.PREVIEW anywhere in C/AL code in which case the “Print Layout” button is not available.
It’s a good idea anyway when testing your reports, just to look at them in “Print Layout”, since some times this does look very differently from the normal preview.
Microsoft Dynamics UK
Microsoft Customer Service and Support (CSS) EMEA