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    ---------------------------

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.

Error After Restore SQL Backup of NAV 2013 Database

Hi all, we are facing a conman issue during restoring a SQL Database backup restored for NAV 2013. While Trying to run object from Object Designer we get below listed error (even the service is configured properly) - --------------------------- Microsoft Dynamics NAV Development Environment --------------------------- There are no NAV Server instances available for this database. You must ensure that a NAV Server instance is running and is configured to use the database before you perform this activity. --------------------------- OK    ---------------------------