Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

Calling a report from a class

Posted on by

Hello,

I'm calling a report (extend ObjectRun) from a class (Extends RunBaseReport) from the run method with the following code:

while SELECT myTable {

  args = new Args (reportStr (myReport));

  args.caller (this);
  args.record (myTable);

  rpt = new ReportRun (args);

  rpt.printJobSettings ().setTarget (printMedium::File);
  rpt.printJobSettings ().format    (printFormat::PDF);
  rpt.printJobSettings ().fileName  (shipListShipToTbl.filename);

  rpt.report ().interactive (false);
  rpt.query  ().interactive (false);

  rpt.init ();
  rpt.run ();

}

Is there a way to wait for the report to finish before processing the record?  And receive status, i.e. terminate the loop if the report fails from some reason?  Unfortunately I can't or prefer not to modify the called report.

Jim Richardson

  • RE: Calling a report from a class

    Jacob,

    Thank you for your response, although the light went off and I realized the call to "rpt.run ()" is a synchronous call.  Therefore, I don't need to wait, the call doesn't return until the run method is finished.

    Now the question is how to prevent the lastValueElementName method from calling the report.  

    Jim R.

  • Suggested answer
    jasman Profile Picture
    jasman 1,411 on at
    RE: Calling a report from a class

    Maybe you could try:

    while SELECT myTable {

     args = new Args (reportStr (myReport));

     args.caller (this);

     args.record (myTable);

     rpt = new ReportRun (args);

     rpt.printJobSettings ().setTarget (printMedium::File);

     rpt.printJobSettings ().format    (printFormat::PDF);

     rpt.printJobSettings ().fileName  (shipListShipToTbl.filename);

     rpt.report ().interactive (false);

     rpt.query  ().interactive (false);

     try {

         rpt.init ();

         rpt.run ();

     }

     catch

     {

         break;

     }

    }

    Mind you I haven't tried it.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,252 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,089 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans