Microsoft Dynamics NAV 2013 Report Printing Oddity (and a Solution!)
I have to give credit to my colleague, Suresh Kulla, for helping me out with this one, since I only figured it out after he explained it to me.
I was working on a report yesterday when something maddening happened. I was making some customizations to the Service Quote report in Microsoft Dynamics NAV 2013 for a customer, when I ran into an issue that threatened to tear away my tenuous grasp on what remains of my sanity.
Like a lot of document reports, the Service Quote report has a GetData() and SetData() set of functions designed to let you share data from the tablix of the report on the header and footer sections of the report. Fresh from the box, the Service Quote report actually has several GetData() calls in textboxes in the header section to fill in the customer address, quote number, date, and other fields.
The customer wanted me to move the header fields around so that some of the things that had been on the right were now on the left, and some of the things on the left were now on the right, and some stuff was to be moved up and down, and there were one or two new fields to be added…nothing special, really. Just normal report changes.
And then it happened. I moved the company logo up, I moved some of the fields over to the right side of the report, and I moved the hidden GetData() textboxes to make some room. When I ran the report in Print Preview, everything looked OK; the logo showed up, the company address and customer address printed, and the quote number and date were fine. But I’m a paranoid fellow—and as stated earlier (and like many parents of small children), I am only somewhat holding on to my sanity. As such, I did not trust the Print Preview to give me an accurate picture of the reality of printing the report, and so I tried printing it as a PDF.
Microsoft Dynamics NAV 2013’s print to PDF functionality does a much better job of actually showing you what the report will look like. I don’t know exactly how or why this is true, but I suspect that there’s a PDF printer of some sort built into the Dynamics NAV client (or maybe the SSRS client) that actually uses the same logic as a paper printer would. This makes some sense, because PDFs are essentially designed to be paper documents viewable by computer.
So, when I tried printing the report to PDF, the company address, quote number, and quote date were all missing. I tried everything I could think of to get them to show up—moving stuff around, hiding things, sneaking values around into other fields, infernal pacts with ancient slumbering monstrosities, the whole nine yards. Nothing worked.
And so I cried out to my fellow developers for help, and lo, Suresh did answer my cries and suggest something. He said that I should try moving the GetData() textboxes up to the top left corner of the report. I tried it, and sure enough, that fixed my problem. The company address, quote number, and quote date all appeared just fine.
I do not have an explanation for this behavior. My hypothesis is that the Dynamics NAV report writer is executing the code in textboxes in the order that the boxes are laid out on the page, starting in the upper left and then moving right and down. Someone who knows what’s going on a little better than I can confirm or deny that one can feel free to leave a comment, but it seems reasonable to me, given my issues and my results yesterday.
If you have any further questions on reporting functionality in Microsoft Dynamics NAV, contact ArcherPoint. Read more blogs by Tom Hunt and be sure to check out the ArcherPoint Developer Blog, written specifically for Dynamics NAV developers.