Report Output Monitoring

Due to some requests i will post my solution to print out documents, make a PDF, and automatically send them by email down here. So i start by explaining some basic things: You will have to add 2 or 3 lines of code to every report which you want to be able to be sent by PDF and the routine that calls the printing of the report. You must also create 1 Table, 1 Codeunit and 1 Form. Thats all. Some different code modifications may be neccesary though (Codeunit Print Document e.g.). The technique is the following: The moment a report is being started (Request Form) i insert a record into a temporary table that defines some basic settings like who is the recipient and the address a.s.o. This temporary table is managed inside the codeunit, which is SingleInstance so throughout the whole Navision Session we have the same variables. The primary key of the table is the ID of the report. From the report, those settings can be modified, changed to another recipient a.s.o. The report itself must be run with RUNMODAL in order to stop execution of the code until the report has finished. Now inside that table the filename of the report-output is specified and retrieved and sent via email. Go retrieve it and send it. Example: ROMMgt.InsertROMEntry(Report.OBJECTID(false)); // creates an entry Report.RUNMODAL; // Inside the report the entry can be modified ROMMgt.FinalizeEntry(Report.OBJECTID(false)); // get the produced file and do something with it I will add the bet version of the solution right here. But note: This is aint going to be a very tested version. Customer / Vendor Data is not copied and the email address will have to be inserted manually. It is heavily under development. Any suggestions welcome.
Text File: read ROMManagement.txt ( 8609bytes ) if you want to activate that thing now you will have to do the following (Example for Sales Invoice) goto the sales invoice header trigger PrintRecords. which should look that way: PrintRecords(ShowRequestForm : Boolean) WITH SalesInvHeader DO BEGIN COPY(Rec); ReportSelection.SETRANGE(Usage,ReportSelection.Usage::“S.Invoice”); ReportSelection.SETFILTER(“Report ID”,’<>0’); ReportSelection.FIND(’-’); REPEAT ROMMgt.CreateROM('Report '+FORMAT(ReportSelection.“Report ID”), SalesInvHeader.“Sell-to Contact No.”); REPORT.RUNMODAL(ReportSelection.“Report ID”,ShowRequestForm,FALSE,SalesInvHeader); ROMMgt.CompleteROM('Report '+FORMAT(ReportSelection.“Report ID”)); UNTIL ReportSelection.NEXT = 0; END; All you need now is a printer drivere which lets you specify the file he is going to create. With this thing you can send almost everything with any format. Needs a lot of improvement though.