Print sales invoice report through code

 internal final class printSOInvoiceReport

{

    /// <summary>

    /// Class entry point. The system will call this method when a designated menu 

    /// is selected or when execution starts and this class is set as the startup class.

    /// </summary>

    /// <param name = "_args">The specified arguments.</param>

    public static void main(Args _args)

    {

        CustInvoiceJour custInvoiceJour = CustInvoiceJour::findFromSalesId('test98');


        str ext = SRSPrintDestinationSettings::findFileNameType(SRSReportFileFormat::PDF, SRSImageFileFormat::BMP);

        PrintMgmtReportFormatName printMgmtReportFormatName = PrintMgmtDocType::construct(PrintMgmtDocumentType::SalesOrderInvoice).getDefaultReportFormat();

                                     

        SalesInvoiceContract salesInvoiceContract = new SalesInvoiceContract();

        salesInvoiceContract.parmRecordId(custInvoiceJour.RecId);


        SrsReportRunController  srsReportRunController = new SrsReportRunController();

        srsReportRunController.parmReportName(printMgmtReportFormatName);

        srsReportRunController.parmExecutionMode(SysOperationExecutionMode::Synchronous);

        srsReportRunController.parmShowDialog(false);

        srsReportRunController.parmReportContract().parmRdpContract(salesInvoiceContract);


        SRSPrintDestinationSettings printerSettings = srsReportRunController.parmReportContract().parmPrintSettings();

        printerSettings.printMediumType(SRSPrintMediumType::File);

        printerSettings.fileFormat(SRSReportFileFormat::PDF);

        printerSettings.parmFileName(custInvoiceJour.InvoiceId + ext);

        printerSettings.overwriteFile(true);

                    

        srsReportRunController.startOperation();

    }


}

Comments

Popular posts from this blog

On clicked event of form button in D365 X++

Finding unit price of item from trade agreement through code AX X++

Create Sales Line Through Code AX X++ D365 Finance & Operations