Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 52382

RUNREQUESTPAGE, EXECUTE, PRINT, SAVEAS in NAV

$
0
0

…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: areports 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



Viewing all articles
Browse latest Browse all 52382

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>