Axapta 打开“从代码打印报告”对话框

Axapta 打开“从代码打印报告”对话框,axapta,dynamics-ax-2009,x++,Axapta,Dynamics Ax 2009,X++,我试图强制打开打印对话框,以便用户只需设置电子邮件地址并按ok。我已经找到了很多关于如何在没有打印对话框的情况下将报表打印到文件或打印机的教程,但这不是我想要的 通常,要通过电子邮件发送报告,用户会显示报告,单击工具栏中的打印图标,然后选择电子邮件并发送报告。我想自动删除前两步 到目前为止,这是我多次尝试的其中一次,但都无济于事 void emailInvoice() { Args args; ReportRun rr; Report

我试图强制打开打印对话框,以便用户只需设置电子邮件地址并按ok。我已经找到了很多关于如何在没有打印对话框的情况下将报表打印到文件或打印机的教程,但这不是我想要的

通常,要通过电子邮件发送报告,用户会显示报告,单击工具栏中的打印图标,然后选择电子邮件并发送报告。我想自动删除前两步

到目前为止,这是我多次尝试的其中一次,但都无济于事

void emailInvoice()
{
Args                args;
ReportRun           rr;
Report              rb;
PrintJobSettings    pjs;
CustInvoiceJour     record;
;

select record where record.RecId == 5637175089;

args = new Args("SalesInvoice");
args.record(record);
args.parmEnum(PrintCopyOriginal::OriginalPrint);

// Set report run properties
rr = new ReportRun(args,'');
rr.suppressReportIsEmptyMessage(true);
rr.query().interactive(false);

// set report properties
rb = rr.report();
rb.interactive(true);

// set print job settings
pjs = rr.printJobSettings();
pjs.fileName(strfmt("C:\\Users\\gbonzo\\Desktop\\%1.pdf", record.SalesId));
pjs.fitToPage(true);
// break the report info pages using the height of the current printer's paper
pjs.virtualPageHeight(-1);


// force PDF printing
pjs.format(PrintFormat::PDF);
pjs.setTarget(PrintMedium::Mail);
pjs.viewerType(ReportOutputUserType::PDF);

// lock the print job settings so can't be changed
// X++ code int the report may try to change the destination
// to the screen for example but this does not make
// sense when running a report here
pjs.lockDestinationProperties(true);

// Initialize the report
rr.init();

rr.run();
}

提前感谢您的帮助

在调用run()方法之前,必须先调用ReportRun类的prompt()方法


prompt()方法将显示打印对话框。如果您想让用户更方便,可以使用SysMailer类,请查看quickSend()方法。

您是否尝试开发一个RunBase标准对话框类(如果需要选择打印机,请使用RunBaseBatchPrintable)来获取所需的所有对话框字段,以编程方式运行报告,并传递所有所需参数?我很肯定它会起作用,并且可能会留下一个更干净的代码来分隔用户交互所需的逻辑报告

请阅读以下示例:


我刚刚试过,当我按ok时,它只会显示报告。我选择了“邮件”并输入了一个收件人,但它没有正常工作。有时,它会抛出一个错误“ClrObject静态方法调用错误”。@GregBonzo查看此错误以避免我怀疑的错误:1)CustInvoiceJour记录;和2)args=新args(“销售发票”);我需要打印机对话框,以便我可以从那里发送电子邮件,而不是实际打印
if (rr.prompt())
{
    rr.run();
}