Tag: Reports

Print to different trays in NAV – Part 4

This post is part of a series of posts where I explain how to print to different trays in NAV.

  1. Print to different trays in NAV – Part 1
  2. Print to different trays in NAV – Part 2
  3. Print to different trays in NAV – Part 3
  4. Print to different trays in NAV – Part 4

In this forth and last part, we’ll simply print a sales invoice respecting the following requirements:

  1. The first page should print from first tray where we will use a colored paper,
  2. The last page should print from second tray where we will use preprinted paper where we can read general terms and conditions in the back,
  3. Other pages should print from the lower tray for example.

To fulfill this requirement, we’ll use the options already described in Part 1.

For test purpose, I will save report “Sales – Invoice” (ID 206) under a new name and number. I’ll adjust properties as below:

  • PaperSourceFirstPage  = Custom 2,
  • PaperSourceDefaultPage = Lower,
  • PaperSourceLastPage = Custom 3.

Then I’ll create an invoice, post, and print it. Voilà !

Sources and examples are available here.

That’s great. But when you print multiple invoices or when you print multiple copies of your invoice, you’ll quickly notice that NAV does not pages in the right trays.

Unfortunately, this is a limitation in Windows Client / RTC because:

  • RDLC does not support PAPERSOURCE,
  • RDLC uses report properties for physical pages only.

Of course, this limitation is not relevant for NAV 2009 R2 Classic Client and older versions because you can force PAPERSOURCE in the code.

But hey, you should upgrade your NAV if you still use NAV 2009 R2 or older. So, you’ll face these limitations soon 😀

This was the last part of this blog post series. I hope it will help someone. Please share your ideas or just say hello if you like my work.


This blog is available also on Microsoft Dynamics NAV Community

Print to different trays in NAV – Part 3

This post is part of a series of posts where I explain how to print to different trays in NAV.

  1. Print to different trays in NAV – Part 1
  2. Print to different trays in NAV – Part 2
  3. Print to different trays in NAV – Part 3
  4. Print to different trays in NAV – Part 4

In this third part, we’ll see how you can find what are available trays in your printer.

To do this, I will explain two solutions.

Solution 1:

This solution is based on a simple tool called “FindTrays”. This tool was kindly shared by Timo Lässer from German NAV community msdynamics.de. You can directly download FindTrays from this link.

You can get available trays by executing this command line:

.\FindTrays.exe “MyPrinterName” > .\AvailableTrays.txt

How do you get your printer’s name? Simple, just go to your printer properties and you’ll find it under the general tab.

Solution 2:

The second solution I suggest is based on NAV. The idea is to create a simple report that prints the tray number using:

  • PAPERSOURCE function for NAV 2009 R2 Classic Client and older version,
  • Properties PaperSourceFirstPage, PaperSourceDefaultPage and PaperSourceLastPage for version with Windows Client / RTC (i.e. NAV 2013 and later).

Sources and examples are available for download here. Enjoy!

In the fourth part, we’ll apply what we learned, and we’ll discuss some NAV limitations.


This blog is available also on Microsoft Dynamics NAV Community

Print to different trays in NAV – Part 2

This post is part of a series of posts where I explain how to print to different trays in NAV.

  1. Print to different trays in NAV – Part 1
  2. Print to different trays in NAV – Part 2
  3. Print to different trays in NAV – Part 3
  4. Print to different trays in NAV – Part 4

In this second part, we’ll see how you can test your printing in different trays.

If you need to test your printing you will, of course, need a printer that support printing in different trays. But what if you don’t have such a printer? Or, what if you -like me- hate to waste paper on your tests?

The answer is Bullzip PDF printer. In fact, this proprietary PDF virtual printer allows to add virtual trays. I’ll let you read complete explanation in Bullzip Knowledge Base.

Just in case the link is down, I’ll quickly explain the steps hereafter. All you need to do is:

  1. Download and install the virtual printer with default parameters (adjust if needed),
  2. Open, as admin, the “BULLZIP.PPD” file located in “C:\Windows\System32\spool\drivers\x64\3\“,
  3. Add the lines below to the end of the file and save it:

*InputSlot Tray1/Tray 1: “gsave /Times-Roman findfont 30 scalefont setfont newpath 10 10 moveto 1 0 0 setrgbcolor (Tray 1) show grestore”
*InputSlot Tray2/Tray 2: “gsave /Times-Roman findfont 30 scalefont setfont newpath 10 10 moveto 1 0 0 setrgbcolor (Tray 2) show grestore”
*InputSlot Tray3/Tray 3: “gsave /Times-Roman findfont 30 scalefont setfont newpath 10 10 moveto 1 0 0 setrgbcolor (Tray 3) show grestore”
*InputSlot Tray4/Tray 4: “gsave /Times-Roman findfont 30 scalefont setfont newpath 10 10 moveto 1 0 0 setrgbcolor (Tray 4) show grestore”
*InputSlot Tray5/Tray 5: “gsave /Times-Roman findfont 30 scalefont setfont newpath 10 10 moveto 1 0 0 setrgbcolor (Tray 5) show grestore”

You can download the file I created here (delete .doc from the extension).

Now that the printer is ready, let’s see how you can find out what are the available trays in your printer. The answer is in part 3.

P.S 1: this blog is primarily addressed for NAV developers.

P.S 2: this blog could be of use for none-NAV developers also as it explains a solution to create virtual printer with different trays.

P.S 3: The same trick works also for PDFCreator (i.e. add virtual trays to the virtual printer). So, you can try it with your preferred virtual printer. The PPD file is available in the same location “C:\Windows\System32\spool\drivers\x64\3\PDFCREAT.PPD”.


This blog is available also on Microsoft Dynamics NAV Community

Print to different trays in NAV – Part 1

This post is part of a series of posts where I explain how to print to different trays in NAV.

  1. Print to different trays in NAV – Part 1
  2. Print to different trays in NAV – Part 2
  3. Print to different trays in NAV – Part 3
  4. Print to different trays in NAV – Part 4

In this first part, we’ll quickly talk about options available in NAV that allow printing to different trays.

First, let’s check properties of report “Sales – Invoice” (ID 206):

ReportProperties.jpg

As you can see there are three properties that will allow you select the tray where the page should print. Below, you can read help from MSDN:

  1. PaperSourceFirstPage Property
  2. PaperSourceDefaultPage Property
  3. PaperSourceLastPage Property

Available values for each property are described here: Paper Sources and Tray Numbers This link refers to “Norway Local Functionality”, though it explains all available trays numbers in any NAV database (W1 and Localizations).

P.S: In NAV 2009 R2 and older versions, the available options are PaperSourceFirstPage and PaperSourceOtherPages.

In the next blog, I will explain how you can try those options without having a printer with different trays.


This blog is available also on Microsoft Dynamics NAV Community

How to list “ProcessOnly” Reports in Dynamics NAV 2009

I was doing my “daily NAV tour” on Mibuso and NAV Community forums when I spotted the following question:

I have about 300 new reports in my nav database and I need to write down the names of only those that are not ProcessingOnly. Do you know any smart way how to do this quick?

A member suggested an answer. But it applies to NAV new versions only (2015 and later). I could not resist the challenge. Hence my blog post to suggest a solution that applies for all old NAV versions (all versions might be a big word because I tested the code in a 2009 R2 database only 😉 )

Let’s get straight to the point. Here are the variables I used:

NameDataTypeSubtypeLength
TempObjectRecordAllObj 
AllObjRecordAllObj 
ObjectMetadataRecordObject Metadata 
XMLDocumentAutomation‘Microsoft XML, v6.0’.DOMDocument60 
InStrInStream  
TempFileFile  
TempFileNameText 250
TempStringText 1024

And the code:

ObjectMetadata.SETRANGE(“Object Type”, ObjectMetadata.”Object Type”::Report);
// Filter On report ID if needed
// ObjectMetadata.SETFILTER(“Object ID”, ‘MyFilter’);
IF ObjectMetadata.FINDSET THEN
REPEAT
ObjectMetadata.CALCFIELDS(Metadata);
IF ObjectMetadata.Metadata.HASVALUE THEN BEGIN
TempFileName := DELCHR(TEMPORARYPATH + FORMAT(CREATEGUID) + ‘.xml’, ‘=’, ‘{}-‘);

TempFile.CREATE(TempFileName);
TempFile.WRITEMODE := TRUE;
TempFile.TEXTMODE := TRUE;

ObjectMetadata.Metadata.CREATEINSTREAM(InStr);
InStr.READTEXT(TempString, 1024);
WHILE NOT InStr.EOS DO BEGIN
CLEAR(TempString);
InStr.READTEXT(TempString, 1024);
TempFile.WRITE(TempString);
END;

TempFile.CLOSE;

IF ISCLEAR(XMLDocument) THEN
CREATE(XMLDocument);

XMLDocument.load(TempFileName);
FILE.ERASE(TempFileName);

// 1 is ProcessOnly, 0 Others
IF XMLDocument.selectSingleNode(‘Report/ProcessingOnly’).text = ‘0’ THEN BEGIN
AllObj.GET(ObjectMetadata.”Object Type”, ObjectMetadata.”Object ID”);

TempObject.INIT;
TempObject.TRANSFERFIELDS(AllObj);
TempObject.INSERT;
END;
END;
UNTIL ObjectMetadata.NEXT = 0;

FORM.RUNMODAL(FORM::”All Objects”, TempObject);

And of course, the code adapted for NAV new versions (NAV 2016 in my test) 😉

NameDataTypeSubtype
TempObjectRecordAllObj
AllObjRecordAllObj
TempBlobRecordTempBlob
ObjectMetadataRecordObject Metadata
XMLDOMManagementCodeunitXML DOM Management
XmlDocumentDotNetSystem.Xml.XmlDocument.’System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

ObjectMetadata.SETRANGE(“Object Type”, ObjectMetadata.”Object Type”::Report);
// ObjectMetadata.SETFILTER(“Object ID”, ‘3’);
IF ObjectMetadata.FINDSET THEN
REPEAT
ObjectMetadata.CALCFIELDS(Metadata);
IF ObjectMetadata.Metadata.HASVALUE THEN BEGIN
TempBlob.Blob := ObjectMetadata.Metadata;
XMLDOMManagement.LoadXMLDocumentFromText(TempBlob.ReadAsText(”, TEXTENCODING::UTF8), XmlDocument);

IF XMLDOMManagement.FindNodeText(XmlDocument, ‘Report/ProcessingOnly’) = ‘0’ THEN BEGIN
AllObj.GET(ObjectMetadata.”Object Type”, ObjectMetadata.”Object ID”);

TempObject.INIT;
TempObject.TRANSFERFIELDS(AllObj);
TempObject.INSERT;
END;
END;
UNTIL ObjectMetadata.NEXT = 0;

PAGE.RUNMODAL(PAGE::”All Objects”, TempObject);

This blog is available also on Microsoft Dynamics NAV Community

© 2023 NAV NAB BLOG

Theme by Anders NorenUp ↑