Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Get a PDF Stream for F...
Finance forum
Answered

Get a PDF Stream for FreeTextInvoice report

Posted on by 108
Hi there,
 
Can you guide me on how can I get the PDF Stream of Free text Invoice Print?
  • Verified answer
    ShahzaibAhmed52 Profile Picture
    ShahzaibAhmed52 108 on at
    Get a PDF Stream for FreeTextInvoice report
    Thanks, Martin 
     
    I found the issue the report contained duplicate parameters "SuppressDepreciationOfPaymentSection" and 'SuppressDepreciationOfPaymentSection1".
    I just removed the other parameter from the report designer and it worked for me.
  • Martin Dráb Profile Picture
    Martin Dráb 228,493 Most Valuable Professional on at
    Get a PDF Stream for FreeTextInvoice report
    Okay, you should have given us this information as the beginning.
     
    Do you see a value of the parameter in parameterValueArray?
  • Verified answer
    ShahzaibAhmed52 Profile Picture
    ShahzaibAhmed52 108 on at
    Get a PDF Stream for FreeTextInvoice report
    I need a PDF File stream of the report and then attach an XML with the pdf and upload it to an SFTP server.
     
    FreeTextInvoiceContract     contractFree = new FreeTextInvoiceContract();
            FreeTextInvoiceController   controllerFree = new FreeTextInvoiceController();
            SRSReportRunService         srsReportRunService = new SrsReportRunService();
            SRSReportExecutionInfo      executionInfo = new SRSReportExecutionInfo();
            CustInvoiceJour             custInvoiceJour;
            CustInvoiceTable            custinvoiceTable = _args.record();
    
            info(any2Str(custinvoiceTable.InvoiceId));
            select custInvoiceJour where custInvoiceJour.InvoiceId == custinvoiceTable.InvoiceId;
    
            Args                        args = new Args(), argsMenuFunction = new Args();
            str                         ruta, rutaCliente;
    
            Map                                 reportParametersMap;
            SRSProxy                            srsProxy;
            SRSPrintDestinationSettings         settings;
            System.Byte[]                       reportBytes = new System.Byte[0]();
            Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[]  parameterValueArray;
    
            args.record(custInvoiceJour);
            args.parmEnum(PrintCopyOriginal::Copy);
            args.parmEnumType(enumNum(PrintCopyOriginal));
            args.parm("Report");
    
            contractFree.parmPrintCopyOriginal(PrintCopyOriginal::Copy);
            contractFree.parmInstanceType(PrintMgmtDocInstanceType::Copy);
            contractFree.parmCustInvoiceJourRecId(custInvoiceJour.RecId);
            contractFree.parmSuppressDepreciationOfPaymentSection(true);
    
            controllerFree.parmArgs(args);
            controllerFree.parmReportName(ssrsReportStr(FreeTextInvoiceCopy1, MZNUKReport_AR));
            controllerFree.parmShowDialog(false);
            controllerFree.parmLoadFromSysLastValue(false);
            controllerFree.parmReportContract().parmRdpContract(contractFree);
            controllerFree.parmReportContract().parmRdlContract().parmLanguageId(custInvoiceJour.LanguageId);
            controllerFree.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    
            settings = controllerFree.parmReportContract().parmPrintSettings();
            settings.printMediumType(SRSPrintMediumType::File);
            settings.fileName(strFmt('%1.pdf', custinvoiceTable.InvoiceId));
            settings.fileFormat(SRSReportFileFormat::PDF);
    
            controllerFree.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration());
            controllerFree.parmReportContract().parmReportExecutionInfo(executionInfo);
    
            srsReportRunService.getReportDataContract(controllerFree.parmreportcontract().parmReportName());
            srsReportRunService.preRunReport(controllerFree.parmreportcontract());
            reportParametersMap = srsReportRunService.createParamMapFromContract(controllerFree.parmReportContract());
            parameterValueArray = SrsReportRunUtil::getParameterValueArray(reportParametersMap);
    
            srsProxy = SRSProxy::constructWithConfiguration(controllerFree.parmReportContract().parmReportServerConfig());
    
            reportBytes = srsproxy.renderReportToByteArray(controllerFree.parmreportcontract().parmreportpath(), parameterValueArray, settings.fileFormat(), settings.deviceinfo());
    this the code I am using to do so. but I am facing an error now that says "This report requires a default or user-defined value for the report parameter 'SuppressDepreciationOfPaymentSection'. To run or subscribe to this report, you must provide a parameter value."
    ​​​​​​​I receive this when SRSProxy.renderReporttoByteArray() is called.

    Can you help me out with the solution to this issue?
  • Martin Dráb Profile Picture
    Martin Dráb 228,493 Most Valuable Professional on at
    Get a PDF Stream for FreeTextInvoice report
    Can  you tell us more about your scenario, please?
     
    I'm assuming that you want to print an SSRS report to PDF and then take the data of the file and do something else with it then sending it to a printer. Is it so?

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans