Quantcast
Channel: Dynamics 365 Business Central/NAV User Group
Viewing all articles
Browse latest Browse all 11285

Forum Post: RE: Print different data on report while it running from different actions on page

$
0
0
Hi AmiJoshi, As suggested what you need is to run the report with two different filter sets. That can be done very simple with the RUNMODAL function. You didn't mention which version of NAV you are using? If you are using NAV 2016 (or was it already in 2015?), then you can do it a bit smarter. You start by defining two different parameter sets, which you then can edit later if you need to. // Use the REPORT.RUNREQUESTPAGE function to run the request page to get report parameters XmlParameters := REPORT.RUNREQUESTPAGE(206); CurrentUser := USERID; // Save the request page parameters to the database table WITH ReportParameters DO BEGIN // Cleanup IF GET(206,CurrentUser) THEN DELETE; SETAUTOCALCFIELDS(Parameters); ReportId := 206; UserId := CurrentUser; Parameters.CREATEOUTSTREAM(OStream,TEXTENCODING::UTF8); MESSAGE(XmlParameters); OStream.WRITETEXT(XmlParameters); INSERT; END; CLEAR(ReportParameters); XmlParameters := ''; // Read the request page parameters from the database table WITH ReportParameters DO BEGIN SETAUTOCALCFIELDS(Parameters); GET(206,CurrentUser); Parameters.CREATEINSTREAM(IStream,TEXTENCODING::UTF8); IStream.READTEXT(XmlParameters); END; // Use the REPORT.SAVEAS function to save the report as a PDF file Content.CREATE('TestFile.pdf'); Content.CREATEOUTSTREAM(OStream); REPORT.SAVEAS(206,XmlParameters,REPORTFORMAT::Pdf,OStream); Content.CLOSE; // Use the REPORT.EXECUTE function to preview the report REPORT.EXECUTE(206,XmlParameters); // Use the REPORT.Print function to print the report REPORT.PRINT(206,XmlParameters); The example above is from the help text in NAV, but shows very good how you first create a table where you store the filter parameters. Then it shows how to use this filter set to both save as pdf, print and preview from the code. Pretty smart right? [:)] But of course you can also just do it - the old fashioned way!

Viewing all articles
Browse latest Browse all 11285

Trending Articles