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)

ReportRun Controller "losing" print setting when run from ProdMulti class

(0) ShareShare
ReportReport
Posted on by

I am trying to print a SSRS report from code, w/ no menu being popped up. When I run this bit of code from an AX job it works perfectly:

static void Job25(Args _args)
{
  str _prodId='12345';
  SrsReportRunController reportRunController;
  myController parmData;
  //get users default printer from User options
  XX_PrinterName printerName = SysUserInfo::find().xx_PrinterName;

// Create the report run controller
reportRunController = new SrsReportRunController();
reportRunController.parmReportName(ssrsReportStr(reportName,report));
reportRunController.parmLoadFromSysLastValue(false);

// Set printer settings (you can print to file, format, filename, etc).
reportRunController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::Printer);
  reportRunController.parmReportContract().parmPrintSettings().printerName(printerName);

  parmData = new myController();
  parmData.parmProdId(_prodId);

  //set the execution mode to Synchronous
  reportRunController.parmExecutionMode(SysOperationExecutionMode::Synchronous);

  reportRunController.parmReportContract().parmRdpContract(parmData);
  // Run the report
  reportRunController.run();
}

Info message: Report XXX was sent to printer "...printer name...."

I have this same bit of code in the ProdMultiSchedulingJob class, in the run method
// Only run when the Prod Order is not Stopped.
if (!WHSProdTable::find(prodParmScheduling.ProdId).Stopped)
{
// Only run when the Prod Order has no active work.
if(!WHSProdTable::isWorkActiveForProdOrder(prodParmScheduling.ProdId))
{
this.initProdTable(prodParmScheduling.ProdId).status().runJobScheduling(prodParmScheduling,false,prodPurch,this, wrkCtrScheduler);
//print here
XX_printSSRSRpeort(prodParmScheduling.ProdId);
}
else
{
warning("...");
}
}

In the SrsReportRunController class, run method...when invoking printerInfo it always returns null.
When the report is run from a menu it shows up fine, and the srsPrintDestSetting variable is exactly the same.

// If the printer is invalid, use the default printer instead.
srsPrintDestSettings = this.parmReportContract().parmPrintSettings();
if (srsPrintDestSettings != null)
{
printerHelper = new Microsoft.Dynamics.AX.Framework.Reporting.Shared.PrinterHelper();
printerInfo = printerHelper.GetPrinterInfo(srsPrintDestSettings.printerName()); //ALWAYS NULL When coming from ProdMulit class

// Check if the device is available
if (printerInfo == null)
{
// Use the default printer
printerSettings = new System.Drawing.Printing.PrinterSettings();
srsPrintDestSettings.printerName(printerSettings.get_PrinterName());
}
}

So in the job it will use the default printer the user selects in their options. But from the class it will default to OneNote2013.

Any ideas?

Thanks!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    I fixed this by creating a class and running the print method on the client

    private static client void runOnClient(ProdId _prodId)

    {

       ....

    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
GL-01081504-0 Profile Picture

GL-01081504-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans