Skip to main content

Notifications

Announcements

No record found.

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: AX7 : Output SSRS Report to docuref

    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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,791 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,488 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans