Report.RUNMODAL not running modally

remco_rauschremco_rausch Member Posts: 68
edited 2011-02-16 in NAV Three Tier
Hi,

I'm having problems with a report running on RTC when trying to print it to PDF. The basic process is as follows:

Set printer selections to Bullzip Printer
Run Report
Reset Printer selections
E-mail the PDF file

If I do this from a classic client it works fine, the file gets printed, attached and e-mailed. When I do this through the RTC, the e-mail code runs first, falls over because the file doesn't exist and then the report gets printed.

My code for this is as follows:


FileName := '\\Neptune\' + SalesHeaderPrm."No." + '.pdf';

PDFEmailMgt.InitBullZip(ReportSelection."Report ID",FileName);
REPORT.RUNMODAL(ReportSelection."Report ID",FALSE,FALSE,SalesHeaderPrm);
PDFEmailMgt.ResetPrinterSelection(ReportSelection."Report ID");

UserSetup.GET(USERID);
SendEmail(FileName,UserSetup."E-Mail")


So for some reason the Report.RUNMODAL always runs last, I was under the impression that if you run it modally it should run in order? I have tried calling the report in a codeunit and then doing a IF Codeunit.RUN THEN; but I get exactly the same result, the codeunit gets run after the rest of the code.

I have also tried to put a sleep(10000) after the report.runmodal, this results in it sleeping for 10 seconds, then running the e-mail code, it falling over and eventually running and printing the report.

The report is too complicated to convert and use SaveAsPDF, the pdf gets created after so all the permissions are fine too.

Any ideas?

Thanks,

Remco

Answers

Sign In or Register to comment.