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 225,985 Super User 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 225,985 Super User 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?

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,768 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,985 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans