web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Get a PDF Stream for FreeTextInvoice report

(0) ShareShare
ReportReport
Posted on by 148
Hi there,
 
Can you guide me on how can I get the PDF Stream of Free text Invoice Print?
I have the same question (0)
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at
    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?
  • Verified answer
    ShahzaibAhmed52 Profile Picture
    148 on at
    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
    237,965 Most Valuable Professional on at
    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
    148 on at
    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans