Source Tables for report in SAVEASPDF
rnjbng
Member Posts: 82
Hi Folks -
I have been asked to create a report that will run through the Report Inbox table save the report as PDF and attach the report to email and send it to the user id in report inbox table. The help I need is to save the report as PDF, I am using
REPORT.SAVEASPDF(REPORTID,FILENAME,REC);
Unfortunately I am not sure how to get the REC from the report inbox table. I have the report ID in the Report Inbox table but to save it as PDF how do I get the REC part. If I am on a Posted Sales invoice I know the record I am on but from Report ID I just don't know how to get the REC part.
Also, in the Report Output field in the Report Inbox table the report is saved in a BLOB field but when I tried to extract the information from BLOB field and create a file it does not like the file when attached causing errors.
Any help is highly..highly..appreciated.
Thanks
RJ.
I have been asked to create a report that will run through the Report Inbox table save the report as PDF and attach the report to email and send it to the user id in report inbox table. The help I need is to save the report as PDF, I am using
REPORT.SAVEASPDF(REPORTID,FILENAME,REC);
Unfortunately I am not sure how to get the REC from the report inbox table. I have the report ID in the Report Inbox table but to save it as PDF how do I get the REC part. If I am on a Posted Sales invoice I know the record I am on but from Report ID I just don't know how to get the REC part.
Also, in the Report Output field in the Report Inbox table the report is saved in a BLOB field but when I tried to extract the information from BLOB field and create a file it does not like the file when attached causing errors.
Any help is highly..highly..appreciated.
Thanks
RJ.
0
Best Answer
-
Hi,
There is a codeunit 419, File Management, which includes a few useful functions to manage importing/exporting data
Try someting like this:ReportInbox.CALCFIELDS("Report output"); TempBLOB.BLOB := ReportInbox."Report output" FileManagement.BLOBExportToServerFile(TempBLOB, ServerFilePath);If you need the file on the client machine addFileManagement.DownloadToFile(ServerFilePath, ClientFilePath);
SlawekSlawek Guzek - www.yitron.co.uk
Business Central, MS SQL Server, Wherescape RED;5
Answers
-
Hi,
You will not be able to find a source record just using the data from the Report Inbox, but you don't need to do so.
The Report Inbox table is a destination, not a source for a report.
The job queue processing code is using the Report Inbox. The job knows the report ID and the record - if the report is supposed to run with some record, and if the report was supposed to print something the actual report output is stored in the Report Inbox table, in the Report Output field.
If you need to print it out you can stream the Report Output to a file, as you've tried. Just remember that the file generated would be a PDF, a Word or an Excel file - check the Output Type column for details. Then you can print generated file opening it in related application and printing it from there.
Slawek
Slawek Guzek - www.yitron.co.uk
Business Central, MS SQL Server, Wherescape RED;0 -
Hi Slawek -
Thanks for your response. I don't want to print the report, I want to save the contents of the field Report output in Report Inbox table to a file and I tried DOWNLOADSTREAM function but it prompts to either Open, Save the file. Unless user intervention is there it won't do anything. Is there any way I can just save the contents of the Report output field value to a file. Thanks for your help.
Regards
RJ0 -
Hi,
There is a codeunit 419, File Management, which includes a few useful functions to manage importing/exporting data
Try someting like this:ReportInbox.CALCFIELDS("Report output"); TempBLOB.BLOB := ReportInbox."Report output" FileManagement.BLOBExportToServerFile(TempBLOB, ServerFilePath);If you need the file on the client machine addFileManagement.DownloadToFile(ServerFilePath, ClientFilePath);
SlawekSlawek Guzek - www.yitron.co.uk
Business Central, MS SQL Server, Wherescape RED;5 -
Many..Many..Many Thanks Slawek, that worked. Thanks for helping me out.
Regards
RJ.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
