web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

I have the same question (0)
  • Suggested answer
    jasman Profile Picture
    1,413 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.

  • Jim Richardson Profile Picture
    on at
    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans