web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Calling a report from a class

(0) ShareShare
ReportReport
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

*This post is locked for comments

  • Suggested answer
    jasman Profile Picture
    1,413 on at

    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.

  • Jim Richardson Profile Picture
    on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans