Printing Carbon Copies in NAV
It never gets boring being a NAV developer for ArcherPoint. Because our clients are in such varied industries, we get a lot of really unique development opportunities and get to work with some great people. In fact, that’s probably the one thing I love most about this job – the unique opportunities to be creative.
One of those clients, Quality Wine and Spirits, has given me a fantastic creative outlet. Enough so, in fact, that they won the 2010 Microsoft Dynamics NAV Excellence in Innovations Award.
Being a distributor of wine and spirits, there are legal requirements related to the delivery and payment of goods. One of those requirements is that the customer receives the invoice at the time of delivery, and a signed copy is retained by the distributor. Back in the days of imprint printing, this was easily accomplished with a multi-page carbon form, with a different color for each page. This allowed them to tell the driver to just “bring back the blue copy”. But when printing from NAV to a laser printer, the multi-page carbon form wasn’t an option.
We found a way to resolve this using a printer with multiple printer trays – each with a different color paper. But then came the issue of setting the report to print to each tray. Which tray you print to in NAV is set using a function of called PAPERSOURCE. Using PAPERSOURCE, you pre-set the tray in which you want to print the report using a statement like this:
Sounds simple, eh? It is…until you have a printer that you have never seen - cannot see - and no idea what the paper bin number (i.e. ‘258’) is for each tray.
I started by searching for an online printer manual, but quickly found out that they don’t give you the paper bin numbers for the trays. The printer installer had no idea what the numbers were either. Then and there I realized I had to devise a way for the printer to communicate the trays to me. So how do you get a printer to give you information you didn’t send it? You get creative!
I did so by writing a report on the data item INTEGER that I named “TrayLoop”, with a second indented data item of INTEGER. Integer is a virtual table with one field, Number, which is an integer. I filtered “TrayLoop” NUMBER equal to the known paper bin numbers (1..11|14|15|256..263). Having the indented INTEGER data item set with a DataItemLink equal TRAYLOOP.Number, I set the report to create a new page per record. On the page I printed the value of Number, which would, because of my filters, be one of the known paper bin numbers.
With the help of the printer installed, we then made sure each paper tray had a unique color paper in it (green, yellow, pink, blue, and white). One quick run of the report, printing several sheets of paper, and the printer began to print in each paper tray – telling us it’s PaperSource bin numbers. It was easy to pick up a sheet of pink paper and know that that the tray with pink papers was 263 because it printed on the pink page and blue was 256 based on the blue page, and so forth. Here’s the report in text format if you need it. Just save it down to your computer, change the object number to something good for your database, and import it.
(Right click on the link above, and select SAVE.)
The rest of the task was easy. The NAV Sales Order (Report 10075) has a looping function already based on the number of copies you request. This is done by setting an INTEGER virtual table filter equal to the number of copies. We just inserted a higher level loop for Integer and called it “TrayLoop”, and set the number of bins we wanted to print from as the filter.
Quality Wine and Spirits had an additional requirement that the items on the final page of 4 that were printed needed to be sorted in order by Inventory Posting Group – but only the final page. We accomplished this by writing the data to a second SalesLine temporary table variable, and sorting the data prior to printing. This page prints in a final print loop of its own.
Based on which page we were printing, we reset the CurrReport.PAPERSOURCE value, which changed the bin.
I’m happy to report that Quality Wine and Spirits now prints from Microsoft Dynamics NAV a 4-page multi-colored copy of their Sales Order, which fits their business requirements.
In the end, it’s not about all the colors of the rainbow coming out of the printer. It’s about making the ERP do what the business needs it to do. They can continue to say to the driver “bring back the blue copy”. Your ERP should never control what your business requirements are. That’s another thing I love about NAV. It’s more flexible than Gumby! If you can dream it – it can do it.