Skip to main content

Navision Classic - Save Report in PDF File as User Defined Path.

Hi all,

Today Let's try to save a classic report in PDF format.

We need to use any third party tool (PDF Printer) which will be used to print report in PDF.

There are plenty of them if you search on the web. I will be using Bullzip Printer for Demo.

For Downloading Bullzip Printer follow the Link.

Download and Install the PDF Printer.

Make sure that during installation you install all the components. Please don't uncheck any of the option as shown below.



After installation Make this printer as system default printer.

For saving report as PDF, you can either Create a new Report / Codeunit.

I will be using codeunit for the demo purpose.

Agenda -

Provide a button on customer card, on click event the report should be saved in PDF as per path defined.


Basic Setup -

1) Path will be user defined.
  Create a new text field in User Setup table and add same to Form (Say - Path to Save Report).

User based on his requirement can specify the path where the PDF file should be saved.



2) Create a Codeunit which will save report in PDF.

  a) Create a function say - CheckSetup().
  b) Create a function say - CustomerStatement(CustNo : Code[20])

First function will be used to check the user setup and path for the report saving.



Second function will run Report Sales Statistics and save it into specified location using BULLZIP.

Function CustomerStatement have a parameter customer no. for which report should get executed.

As its a file related operation required we require a variable for 'Microsoft Scripting Runtime'.FileSystemObject.

As Report need to be save as PDF we need the automation variable of Bullzip.


Function CustomerStatement will -
1) check the user setup.
2) Get Customer.



3) initialize automation of File Variable & BullZip.
4) Check the path existence provided in user setup.
5) Create a file name.



6) Set parameters of Bullzip.

7) Run Report & Save.
8) Clear Bullzip and File.



Other parts are self explanatory except step 6.

In step 6, I have set parameter related to bullzip, that are loading settings, Set Filename, Hide progress bar, suppress error message and allow overwrite.

These parameters can be found in the variable created for bullzip.

Variables Created in codeunit-

BullZipPDF Automation 'Bullzip'.PDFPrinterSettings

UserSetup Record User Setup

Customer Record Customer

File1 Automation 'Microsoft Scripting Runtime'.FileSystemObject

Filename1 Text 250

RunOnceFile Text 250

SalesStat Report Sales Statistics

Now i have added a button in customer menu button where i called codeunit function.



Here is the output when i clicked on button for customer 1000.



I have kept the modified objects in my skydrive folder [Version 2009 R2].

File Name - Save Report in PDF (Classic Client)

Please keep backup of standard objects before importing.

We will see usages of this in future post.

Regards,
Saurav Dhyani

Comments

Post a Comment

Popular posts from this blog

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

RTC Report It is not possible to instantiate the Visual Studio bridge.

Hi all, As a Navision developers I have Multiple Versions of Navision running in single Machine. As discussed Earlier in the post how to run multiple Version of RTC in single machine. So my machine have following details for RTC Versions - NAV 2009 R2    - is installed. NAV 2009 SP1  - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 SP1 IN\ NAV 2009         - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 IN\ This approach has been working great for execution of Classic and RTC Clients. However, after installing Dynamics NAV 2009 R2, if i tried to view the Layout for an NAV 2009 SP1 Report i was getting the following error: ---------------------------  Microsoft Dynamics NAV Classic  ---------------------------  It is not possible to instantiate  the Visual Studio bridge.  ---------------------------  OK    --------------------------- After searchi...

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.