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 :
Finance | Project Operations, Human Resources, ...
Unanswered

Output SSRS Report to docuref

(0) ShareShare
ReportReport
Posted on by 5

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;
}

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

    Hi stephan,

    I am also having same requirement to generate and attach report to DocuRef and ended up with warning internal use only for Sysproxy and other SRS related classes.

    Did you find any alternative solution to archive this?

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 512 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 386

#3
Adis Profile Picture

Adis 259 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans