Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Get a PDF Stream for FreeTextInvoice report

(0) ShareShare
ReportReport
Posted on by 123
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 123 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 230,962 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 123 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 230,962 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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans