通过 X++ 在 Microsoft Dynamics AX 2009 中打印报表
我正在尝试通过单击按钮打印销售确认报告,该按钮已添加到 Microsoft Dynamics AX 2009 中的销售订单详细信息表单中。在该按钮的单击事件中,我编写了以下代码:
void clicked()
{
Args args;
ReportRun reportRun;
SalesFormLetter salesFormLetter;
PrintJobSettings printJobSettings;
CustConfirmJour custConfirmJour;
RecordSortedList list = new RecordSortedList(55);
SalesTable salesTableUpdate;
;
SELECT firstonly custConfirmJour order by ConfirmID desc where custConfirmJour.SalesId == salesTable.SalesId ;
list.ins(custConfirmJour);
args = new Args(ReportStr(SalesConfirm));
printJobSettings = new PrintJobSettings();
printJobSettings.SetTarget(PrintMedium::Printer);
printJobSettings.suppressScalingMessage(true);
salesFormLetter = new SalesFormLetter_Confirm(true);
salesFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());
args.designName("Standard");
args.caller(salesFormletter);
args.parmEnum(PrintCopyOriginal::Original);
args.parmEnumType(enumnum(PrintCopyOriginal));
args.object(list);
reportRun = new ReportRun(args);
reportRun.setTarget(PrintMedium::Printer);
reportRun.init();
reportRun.run();
}
代码运行良好,但问题除外直接在打印机上发送报告,打印预览即将到来。
如果你们中的任何人能让我知道这段代码有什么问题,我将非常感激。
Rgds
哈龙
I am trying to print sales confirmation report on a button click which I have added on Sales Order Detail form in Microsoft Dynamics AX 2009. On click event of that button, I have written following code:
void clicked()
{
Args args;
ReportRun reportRun;
SalesFormLetter salesFormLetter;
PrintJobSettings printJobSettings;
CustConfirmJour custConfirmJour;
RecordSortedList list = new RecordSortedList(55);
SalesTable salesTableUpdate;
;
SELECT firstonly custConfirmJour order by ConfirmID desc where custConfirmJour.SalesId == salesTable.SalesId ;
list.ins(custConfirmJour);
args = new Args(ReportStr(SalesConfirm));
printJobSettings = new PrintJobSettings();
printJobSettings.SetTarget(PrintMedium::Printer);
printJobSettings.suppressScalingMessage(true);
salesFormLetter = new SalesFormLetter_Confirm(true);
salesFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());
args.designName("Standard");
args.caller(salesFormletter);
args.parmEnum(PrintCopyOriginal::Original);
args.parmEnumType(enumnum(PrintCopyOriginal));
args.object(list);
reportRun = new ReportRun(args);
reportRun.setTarget(PrintMedium::Printer);
reportRun.init();
reportRun.run();
}
The code is running fine except on problem that instead of sending the report directly on printer, print preview is coming.
I will be very greateful if anyone of you could let me know what is wrong with this code.
Rgds
Haroon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于您没有发送对任何打印机的引用,因此它必须使用默认打印机,这很可能是 Microsoft XPS 或某些具有显示功能的打印机。
我必须将打印机设置发送到报告(销售发票)并添加一些代码来嗅出任何发送的打印机设置。否则,报告将使用适用于该类型报告的任何打印机设置。让它工作使我能够传递各种打印机设置,如电子邮件、PDF 等......:-)
Since you're not sending in an reference to any printer, it would have to use the default printer, which might very well be Microsoft XPS or some display capable printer.
I had to send in the printersetting to the report (SalesInvoice) and add some code to sniff out any sent printersetting. Otherwise, the report will use whatever printersetting that applies to that type of report. Getting that to work enabled me to pass in various printersettings, like Email, PDF, etc, etc... :-)
如果您不知道用户设置为默认打印机的设备,那么它将始终打印到默认打印机。如果您的默认设置是打印到屏幕(即使您选择了 Print Medium::Printer),它仍然会转到屏幕。我认为您应该选择 PrintMedium::Screen 并让它始终转到屏幕,以便用户可以选择打印机,否则他们可能不知道报告打印在哪里(我有一些用户有奇怪的选择作为默认打印机,可能位于建筑物对面)。
If you do not know the device that the user has set up as the default printer then it will always print to the default printer. If your default settings are to print to screen (even though you selected Print Medium::Printer) it will still go to screen. I would think that you should select PrintMedium::Screen and have it always go to screen so that the user can select a printer, otherwise they may not know where the report printed (I have some users that have odd choices as their default printer, which may be across the building).
试试这个:
通过这段代码,我调用一个报告三次(变量 maxReports),每次它都直接发送到打印机。
try this:
Through this code, I am calling a report Thrice (variable maxReports), everytime it is going directly to the printer.