Tag: Navision

How to: Access timestamp from C/AL

How to access timestamp from C/AL? When you Google/Bing this question, you mainly get three answers:

  1. Short answer: you can’t,
  2. Write a SQL query using ADO.NET,
  3. Create a SQL view and use a linked table on NAV,

When Microsoft introduced NAV 2016, we got a fourth answer described in this blog post by Dynamics NAV Team Blog.

Here is my point of view about these solutions:

  1. Solutions 1: is not a solution,
  2. Solution 2: is like you use a hammer to kill a mosquito,
  3. Solution 3: well, this is not a solution too because:
    • You have to create a view on your database and this will give some headache when you upgrade…
    • You have to consume a table: what if you want to have the timestamp for records from two/three/N tables ? Would you create N dummy views and N linked tables? If it was me, the answer is a big NO.
  4. Solution 4: these is a great and useful improvement but:
    • You may have to customize standard tables (add new field of type BigInteger and set property “SQL Timestamp” to Yes)… Yet another customized table you may need to handle during your upgrades πŸ™
    • What about older versions?

After this short introduction (short?), I get right to the point “here is a fifth solution in three lines of code“:

IF NOT DataTypeManagement.GetRecordRef(_RelatedRecord, RecRef) THEN
EXIT(0);

EVALUATE(timestamp, FORMAT(RecRef.FIELD(0).VALUE));

Want to try it? Here is the fob for Dynamics NAV 2013. In this fob, the function GetTimestamp returns the decimal value for the record’s timestamp.

This solution works for Dynamics NAV 2013 and later. Unfortunately, it does not work for Dynamics NAV 2009 R2 or older.

This blog is available also on Microsoft Dynamics NAV Community

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: Set Up Multiple Web Server Instances for the Microsoft Dynamics NAV Web Client – Part 2

If you enjoyed (or still enjoying?) creating your Web Clients manually like I described in one of my previous posts How to: Set Up Multiple Web Server Instances for the Microsoft Dynamics NAV Web Client – Part 1, so I believe it is time to automate this process a little bit.

To achieve that, I wrote a small PowerShell script. The script is self-explanatory πŸ˜‰

Feel free to use it, or better enhance it πŸ™‚

#Set-ExecutionPolicy RemoteSigned

mkdir ‘C:\Inetpub\wwwroot\MyWebClient’
mkdir ‘C:\ProgramData\Microsoft\Microsoft Dynamics NAV\90\Web Client\MyWebClient\WebClient\Resources\ExtractedResources’
cmd /c icacls ‘C:\ProgramData\Microsoft\Microsoft Dynamics NAV\90\Web Client\MyWebClient\WebClient\Resources\ExtractedResources’ /grant ‘IIS_IUSRS:(OI)(CI)(RX,W)’
copy ‘C:\Inetpub\wwwroot\\DynamicsNAV90\web.config’ ‘C:\Inetpub\wwwroot\MyWebClient\web.config’
Invoke-Expression -Command ‘cmd /c mklink /d “C:\Inetpub\wwwroot\MyWebClient\WebClient” “C:\Program Files\Microsoft Dynamics NAV\90\Web Client”‘

Import-Module WebAdministration
IIS:
New-WebVirtualDirectory -Site ‘Microsoft Dynamics NAV 2016 Web Client’ -Name ‘MyWebClient’ -PhysicalPath ‘C:\Inetpub\wwwroot\MyWebClient’
ConvertTo-WebApplication -PSPath ‘IIS:\Sites\Microsoft Dynamics NAV 2016 Web Client\MyWebClient\WebClient’ -ApplicationPool ‘Microsoft Dynamics NAV 2016 Web Client Application Pool’
New-Item ‘IIS:\Sites\Microsoft Dynamics NAV 2016 Web Client\MyWebClient\WebClient\Resources\ExtractedResources’ -type VirtualDirectory -physicalPath ‘C:\ProgramData\Microsoft\Microsoft Dynamics NAV\90\Web Client\MyWebClient\WebClient\Resources\ExtractedResources’

This blog is available also on Microsoft Dynamics NAV Community

My first blog post… about NAV

It’s been a few years now that I’m reading every single blog post about Dynamics NAV. I learned a lot from all the experts that they share their time with us. Thanks to them, I found answers to a lot of problems I faced in my professional life. Better, I learned enough to overcome challenges on my own.

Lately, I was thinking why not start blogging? So here I am, this is my first blog post. For sure, it is not directly about NAV as I said in the subject; and it will not give you any tip or trick as you expected.

But hey, wait for my next blog post. I already have an idea about its topic… It is about a 100% generic web service client for NAV.

This blog is available also on Microsoft Dynamics NAV Community

© 2022 NAV NAB BLOG

Theme by Anders NorenUp ↑