Running two reports

DnealDneal Member Posts: 103
Hi all,

I have two reports running, one right after the other. The first one shows a request window, but the second does not. The point of that is for the user to print a check and the stub details will print afterwards. They do not want to see two request windows.

Everything works just fine until I cancel the print in the request window. The check cancels but the second report continues to print. I don't understand how to set a flag to find out if the first report ran or not. I feel like I'm missing something simple here.

Any thoughts are appreciated.

Dneal

Comments

  • nunomaianunomaia Member Posts: 1,153
    The code that prints the 2 reports, must check if the first report has printed.
    If in the first report create a global var. If the report is printed then set the global var as true. The code should only print the second report if the var is true.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • Alex_ChowAlex_Chow Member Posts: 5,063
    Where are you putting the code to have the 2nd report print? Or are you just using the standard Navision Report Selection table?
  • DnealDneal Member Posts: 103
    edited 2006-09-11
    Hi all,

    Thanks for your responses.

    How do I check if the first report ran?

    I put the code for the second report in the Document-Print codeunit-229, in the PrintCheck function. I put it right after the first report that prints.

    Am I doing this correctly?

    Thank you,
    Dneal


    GenJnlLine.COPY(NewGenJnlLine);
    ReportSelection.SETRANGE(Usage,ReportSelection.Usage::"B.Check");
    ReportSelection.SETFILTER("Report ID",'<>0');
    ReportSelection.FIND('-');
    REPEAT
    REPORT.RUNMODAL(ReportSelection."Report ID",TRUE,FALSE,GenJnlLine);
    UNTIL ReportSelection.NEXT = 0;

    //MY CODE
    ReportSelection.RESET;
    ReportSelection.SETRANGE(Usage,ReportSelection.Usage::"B.CheckStub");
    ReportSelection.SETFILTER("Report ID",'<>0');
    ReportSelection.FIND('-');
    REPEAT
    REPORT.RUNMODAL(ReportSelection."Report ID",FALSE,FALSE,GenJnlLine);
    UNTIL ReportSelection.NEXT = 0;
    //MY CODE
  • nunomaianunomaia Member Posts: 1,153
    You must change the report.

    For example after the report had run, it sets himselft a var to show that has printed.

    You can see an example in the Posted Invoices Reports. Every time you print a report of that type, the number of printed increase. So you must do a similar thing to with report do you want to check if was printed.

    There isn't a generic way to see if a report was printed.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • markborgesmarkborges Member Posts: 170
    Or maybe you should only put a code in the PostReport trigger calling the stub details report...

    If the user closes the report before, then you have to set some global var to tell it not to run the second report in the PostReport trigger.

    :wink:
    Marcelo Borges
    D365 Business Central Solutions Architect
    BC AL/NAV C/AL Developer
    BC Repositories.com
  • DnealDneal Member Posts: 103
    Or maybe you should only put a code in the PostReport trigger calling the stub details report...

    That's what I have done, works perfectly!

    Thanks all for the help.

    Dneal
Sign In or Register to comment.