最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

从Dynamics 365 FO中的报表查看器用电子邮件发送报表 / Send Report as Email from Report Viewer in Dynamics 365 FO

网络文摘 William 169浏览 0评论
A very common task required by Dynamics 365 Finance and Operations clients is to send a report directly from the report viewer. This can be achieved with a view lines of Code. Here is video on Youtube how it works: image https://www.youtube.com/watch?v=0yQ8wvzzJSg To achieve this create an extension of the SRSReportViewerForm, add a “Send Email” button. Create a OnClicked Event Handler in a Class.
[FormControlEventHandler(formControlStr(SrsReportViewerForm, FormButtonControl1), FormControlEventType::Clicked)] public static void FormButtonControl1_OnClicked(FormControl sender, FormControlEventArgs e) { SrsReportViewerControl ct = sender.formRun().design(0).controlName ( ‚ReportViewerControl‘); object viewerForm = ct.formRun(); SrsReportRunController ctr= viewerForm.controller(); Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService. ParameterValue[] parameterValueArray; Map reportParametersMap; SRSReportRunService srsReportRunService = new SrsReportRunService(); srsReportRunService.getReportDataContract(ctr.parmreportcontract(). parmReportName()); srsReportRunService.preRunReport(ctr.parmreportcontract()); reportParametersMap = srsReportRunService.createParamMapFromContract( ctr.parmReportContract()); parameterValueArray = SrsReportRunUtil::getParameterValueArray( reportParametersMap);         str fileName = ctr.parmReportName()+ „.pdf“; SRSPrintDestinationSettings settings; settings = ctr.parmReportContract().parmPrintSettings(); settings.printMediumType(SRSPrintMediumType::File); settings.fileName(fileName); settings.fileFormat(SRSReportFileFormat::PDF);         SRSProxy proxy = SRSProxy::constructWithConfiguration(SRSConfiguration::getDefaultServerConfiguration()); System.Byte[] reportBytes = proxy.renderReportToByteArray( ctr.parmreportcontract().parmreportpath(), parameterValueArray, settings.fileFormat(), settings.deviceinfo());         if(reportBytes.Length > 0) { SysMailerMessageBuilder messageBuilder = new SysMailerMessageBuilder(); messageBuilder.setSubject(fileName); messageBuilder.addAttachment(new System.IO.MemoryStream( reportBytes), fileName);             SysMailerFactory::sendInteractive(messageBuilder.getMessage()); } }
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址