Skip to main content

RUNREQUESTPAGE, EXECUTE, PRINT, SAVEAS in NAV

RUNREQUESTPAGE, EXECUTE, PRINT, SAVEAS in NAV


…nice reporting functions are available from NAV 2015:  EX: RUNREQUESTPAGE, EXECUTE, PRINT, SAVEAS
MY BEST FUCTION IS:  “RUNREQUESTPAGE” -> “This function lets you run a request page for a report, without actually running the report. When the user clicks OK, the function simply returns a text value, which is an XML document describing the user’s selection and filters of the request page.”; you can use this function also to schedule a report on Job Queue (OnDemand report schedule)
ex: a reports launcher page, scope of this page is run selected reports and generate PDF files after reports printing (or after preview mode report printing)
laucnher
The system use fiunction REPORT.RUNREQUESTPAGE to read and retrieve reports parameters
RUNREQUESTPAGE
XmlParameters:= REPORT.RUNREQUESTPAGE(intIDReport);
… after you get the following XML document as a result:
xml.png
EXECUTE
Now is time to run report with EXECUTE function. This function runs a report without showing a request page. It receives the parameters as an argument of type text, and you can feed the results of the RUNREQUESTPAGE to it. If the report you are executing is a processing-only report, then it will simply silently execute. If it’s a printable report, then it runs in the preview mode.
SAVEAS
SAVEAS function: “It does the same as SAVEASXML, SAVEASPDF, SAVEASEXCEL, and SAVEASWORD, only it does it without showing the request page”.
SOME EXAMPLES:
REPORT.RUNREQUESTPAGE
XmlParameters:= REPORT.RUNREQUESTPAGE(intIDReport);
// Use the REPORT.SAVEAS function to save the report as a PDF file
REPORT.SAVEAS (intIDReport,XmlParameters,REPORTFORMAT::Pdf,OStream);
// Use the REPORT.EXECUTE function to preview the report
REPORT.EXECUTE (intIDReport,XmlParameters);
// Use the REPORT.Print function to print the report
REPORT.PRINT (intIDReport,XmlParameters);
DEMO FUNCTION: “SaveReportPDF”
SaveReportPDF (intIDReport : Integer;txtNomeFile : Text;blnPreview : Boolean;blnPrint : Boolean;blnSavePDF : Boolean;txtPath : Text)
//DEMO .sn
// Use the REPORT.RUNREQUESTPAGE function to run the request page to get report   parameters
CLEAR(XmlParameters);
XmlParameters := REPORT.RUNREQUESTPAGE(intIDReport);
CurrentUser := USERID;
// Use the REPORT.SAVEAS function to save the report as a PDF file
IF blnSavePDF THEN
BEGIN
Content.CREATE(txtPath + txtNomeFile+DELCHR(FORMAT(CURRENTDATETIME,0,'<Day,2>-<Month,2>-<Year> <Hours24>.<Minutes,2>.<Seconds,2>’),’=’,’-:/. ‘)+’.pdf’);
Content.CREATEOUTSTREAM(OStream);
REPORT.SAVEAS(intIDReport,XmlParameters,REPORTFORMAT::Pdf,OStream);
Content.CLOSE;
MESSAGE(‘PDF File written > OK’);
END;
// Use the REPORT.EXECUTE function to preview the report
IF blnPreview THEN
REPORT.EXECUTE(intIDReport,XmlParameters);
// Use the REPORT.Print function to print the report
IF blnPrint THEN
REPORT.PRINT(intIDReport,XmlParameters);
//DEMO .en

Comments

Popular posts from this blog

The Difference Between Microsoft Dynamics NAV and AX

The Difference Between Microsoft Dynamics NAV and AX Microsoft Dynamics offers a variety of ERP solutions. You might say there is a solution for every purpose and every industry. Two of the offerings,  Dynamics NAV  and  Dynamics AX (now part of  Dynamics 365 ) share some of the same features so you might wonder: ‘what are the differences and which is right for my organization?’ Both ERP solutions are highly customizable, available in and adaptable to many languages and currencies used around the world. The two solutions can also be employed in a central location or across diverse satellite locations and are designed to grow as a business grows. Their industry-specific functionality can assure compliance with local and regional requirements. In short, both solutions could rightly be described as comprehensive and well equipped to manage complex requirements of supply chain and inventory. So, what is the difference? Is one better than the other for your...

Journey into Mystery! Working with RecordRef Variables in Microsoft Dynamics NAV

Journey into Mystery! Working with RecordRef Variables in Microsoft Dynamics NAV The RecordRef and FieldRef variable types are used in Microsoft Dynamics NAV to handle working with a record and fields in a record when you don’t necessarily know which record or fields you’ll be handling. In this blog entry, I’ll write about how to work with them. NOTE: These instructions should apply to all versions of Dynamics NAV from version 3.7 up to and including Dynamics NAV 2013 and Dynamics NAV 2013 R2. Writing code around Microsoft Dynamics NAV, you may have seen the RecordRef, FieldRef, and KeyRef variable types. If you’ve never gotten to use them, you probably don’t quite know what they are or how they work. These three variable types are used when you know that you need to work with a record or set of records, but you don’t know exactly which table you’ll need to access. Generally, I’ve used RecordRef variables under two different circumstances. Either I needed to do the same operatio...

How to install a Microsoft Dynamics NAV cumulative update

How to install a Microsoft Dynamics NAV 2018 cumulative update Introduction This article describes how to install a cumulative update for Microsoft Dynamics NAV 2018. You have to recompile all objects after you install a cumulative update. A cumulative update is a cumulative set of files that includes all hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2018. A cumulative update includes files that are separated into the following folders: APPLICATION DVD See  Upgrading the Data to Microsoft Dynamics NAV 2018  for details. How to install the cumulative update files APPLICATION The APPLICATION folder includes the following files: AccumulatedChangeLog.<Locale>.<Build No.>.txt Changelog.<Locale>.<Build No.>.txt CUObjects.<Locale>.<Build No.>.fob Objects.<Locale>.Objects.<Locale>.<Build No.>.txt To install the application files, fol...