I want to output a report in the docuref (in background)
to do this, i used this technique https://meritsolutions.com/render-report-memory-stream-d365-aka-ax7/
Unfortunately, the compiler throws many warnings because the SRS* classes are marked as Internal use only.
Is there another way to do that?
there is the code i use:
public DocuRef PrintReport(DocuTypeId _docuTypeId) { DocuRef addedRecord; SRSPrintDestinationSettings settings; System.Byte[] reportBytes = new System.Byte[0](); SRSProxy srsProxy; SRSReportRunService srsReportRunService = new SrsReportRunService(); SRSReportExecutionInfo executionInfo = new SRSReportExecutionInfo(); Args args = new Args(); if (journalList) { args.object(journalList); } else { args.record(record); } args.caller(caller); // Provide details to controller and add contract controller.parmArgs(args); controller.parmReportName(reportName); controller.parmShowDialog(false); controller.parmLoadFromSysLastValue(false); controller.parmReportContract().parmRdpContract(contract); // Provide printer settings settings = controller.parmReportContract().parmPrintSettings(); settings.printMediumType(SRSPrintMediumType::File); settings.fileName(fileName); settings.fileFormat(SRSReportFileFormat::PDF); // Below is a part of code responsible for rendering the report controller.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration()); controller.parmReportContract().parmReportExecutionInfo(executionInfo); srsReportRunService.getReportDataContract(controller.parmreportcontract().parmReportName()); srsReportRunService.preRunReport(controller.parmreportcontract()); srsProxy = SRSProxy::constructWithConfiguration(controller.parmReportContract().parmReportServerConfig()); // Actual rendering to byte array reportBytes = srsproxy.renderReportToByteArray(controller.parmreportcontract().parmreportpath(), SrsReportRunUtil::getParameterValueArray( srsReportRunService.createParamMapFromContract(controller.parmReportContract()) ), settings.fileFormat(), settings.deviceinfo()); if (reportBytes) { // Converting byte array to memory stream System.IO.MemoryStream stream = new System.IO.MemoryStream(reportBytes); // Upload file to temp storage and direct the browser to the file URL //File::SendFileToUser(stream, settings.parmFileName()); stream.Position = 0; str fileContentType = System.Web.MimeMapping::GetMimeMapping(this.parmFileName()); // Attach the file to a record using stream object addedRecord = DocumentManagement::attachFile(this.parmRecord().TableId,this.parmRecord().RecId,this.parmRecord().DataAreaId, _docuTypeId, stream, this.parmFileName(), fileContentType,'GED file attached'); } return addedRecord; }