Skip to main content

Notifications

Announcements

No record found.

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

  • 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.

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans