Options

Detect blank report after SAVEASHTML

rorrisonrorrison Member Posts: 12
I've just upgraded from Navision 3.70 to NAV2009. I have quite a few reports that are generated and emailed out by NAS. In 3.7, I used code along the lines of
IF EXISTS(ReportFile) THEN
  ERASE(ReportFile);
IF OrderStatus.SAVEASHTML(ReportFile) THEN
  IF EXISTS(ReportFile) THEN
    Send(ReportFile, Recipients, "Overdue Orders");
The SAVEASHTML call would return success but not create a file if the report was blank. In this case, the OrderStatus report would not produce any output if there were no overdue orders. In that case, the email wouldn't be sent.

Now, in NAV2009, SAVEASHTML is creating an HTML file with valid HTML for a blank report. I suppose it's not wrong, but it foils my check for a blank report.

Is there any other good way to check if a report is blank after calling SAVEASHTML?

Thanks,

Randy

Answers

  • Options
    ara3nara3n Member Posts: 9,256
    You can add a function in your report OrderStatus that returns a boolean field if the body section has been printed.

    if OrderStatus.hasanylinesprinted then
    Send();



    You need to create a boolean field in the report and set it to true either in aftergetrecord or onpresection.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    rorrisonrorrison Member Posts: 12
    Thanks. I had thought of that but hoped for a more generic solution, as there are quite a few reports that I'll need to modify, and some of them are rather complicated. Oh well.
  • Options
    ara3nara3n Member Posts: 9,256
    You can check the size of the file. If it's greater than certain size then do something else
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.