ArcherPoint Dynamics NAV Developer Digest - vol 284

ArcherPoint Dynamics NAV Developer Digest - vol 284

The Dynamics NAV and Business Central community, including the ArcherPoint technical staff, is made up of developers, project managers, and consultants who are constantly communicating, with the common goal of  sharing helpful information with one another to help customers be more successful.

As they run into issues and questions, find the answers, and make new discoveries, they post them on blogs, forums, social media…so everyone can benefit. We in Marketing watch these interactions and never cease to be amazed by the creativity, dedication, and brainpower we’re so fortunate to have in this community—so we thought, wouldn’t it be great to share this great information with everyone who might not have the time to check out the multitude of resources out there? So, the ArcherPoint Microsoft Dynamics NAV Developer Digest was born. Each week, we present a collection of thoughts and findings from NAV/BC experts and devotees around the world. We hope these insights will benefit you, too.

Printing Multiple Reports Through One Dynamics 365 Business Central Call

Ryan shares this helpful tip: “If you’re trying to print multiple reports through one call, BC (through the web browser) doesn’t allow it. On Microsoft’s website, they state:

‘Internet browsers can only handle one file per request. Therefore, with the Web client, if this method is called in a repetitive statement (or loop) that generates multiple files, only the last file will be sent to the browser. Alternatively, when designing for the Web client, bundle the files in an archive file (.zip), for example, by using the methods found in codeunit 419 File Management. For more details about this design pattern, see Multi-File Download.’

I remember back in the Bullzip days a confirm() prompt would “stop” the processing long enough for the pdf spool to catch up, so I tried it with AL, and sure enough, it worked for me to get around this issue. You’d just have to consider UX on where to put the confirm().” 

Kyle refers Ryan to Tom Hunt.

Ryan continues: “Ok great; the issue I was trying to solve is looping the list of shipments attached to a packing list. It would only print the last shipment.” 

Tom responds: “I’m doing something kind of like Bullzip used to. I have a “Wait X Time” field in the company setup table, and it gets fed to a SLEEP function call that lets the buffer catch up.” 

Tim Lecander chimes in: “SLEEP always seems like a hack. A last resort fix when anything elegant can’t exist.” 

Kyle drives home Tim’s point with this: 

Bill is stunned: “That can’t even be real…is that romex tapped into the 1 AWG wires below!?!?!” 

Tom gets back to the matter at hand: “SLEEP definitely wasn’t my first choice, but after a while, you accept that the brick wall is harder than your head. It worked OK without SLEEP in my local environment, but when we got to the point where we were doing direct printing from the web client, it broke down and needed some time to get the print queue a second to catch up.” 

“The code for this is a little messy to pull out, since it’s in two separate objects; I’ve amalgamated things into a single file. But the gist of it is that the system does a [Report].SaveAsPdf and saves the file server-side and then uses Sumatra PDF to issue a print command on the server side.  

To pull this off, you have to have your printers set up on the BC server; otherwise, it won’t see the servers to do the printing. There’s also a thing that Kyle has to pull the printer name out of a custom table because we’re doing this for a bunch of different users in different locations.” 

Friday Funny

Kyle: “I got my new fancy Developer keyboard today. Unrelated: I am not a fan of 64-bit processors.”

Chris M: “Congrats! That fancy Enter button means you no longer have to do a carriage return!” 

Tom H: “If you were a REAL developer, you wouldn’t need anything except 0 and 1. That’s all I have, and it’s all I need.” 


If you are interested in Dynamics NAV and Business Central development, be sure to see our collection of NAV/BC Development Blogs.

Read the “How To” blogs from ArcherPoint for practical advice on using Microsoft Dynamics NAV and Dynamics 365 Business Central.

Trending Posts

Stay Informed

Choose Your Preferences
First Name
Last Name
Subscription Options
Your Privacy is Guaranteed