Background: We were creating a report for our customer in Navision 2015. The report was created from scratch and not upgraded. We were using Report Viewer to make changes instead of using the Word Report Layout. The report had multiple fields to be displayed and to work as a new page for every vendor. We thus used Code SetData and GetData functionality.
Symptom: While previewing the report we had a strange problem. Starting from the images to everything in the header will not come up while previewing. However on traversing to multiple pages, they would appear. If we tried to save the report as a pdf directly without previewing then the headers area was completely blank. If we previewed the report, then the Vendor information in the header was changing dynamically. However on saving as PDF it wouldn’t change the header dynamically.
Analysis: Since the header didn’t change automatically, the first area to look was to see that the variables in the CA/L code was reset properly. On debugging we found that it was working OK. Our confusion was due to the fact that the preview worked correctly when traversing forward (Page 1–> Page 10) but not when traversing backward (Page 10 –> Page 1). There was no problem with the CA/L code. The issue had to be with the RDL layout. We then found that the GetData parameters were the ones creating the issue. There is a known issue in RDL where you need to ensure that the SetData is the first code that runs when the report is rendered. Thus putting them at the top left hand corner. This was also found to be correct.
Realization: After a lot of further analysis, we found the issue to be with the fact that the SetData in the header was written as an expression instead of Show/Hide display options visibility setting. When it’s written as an expression, this is not executed when the report is rendered. That’s why the symptom of traversing page forward working. If it’s written as a condition for visibility (and the report rendering executing Top Down), they are executed first thus populating the header fields.