Показать сообщение отдельно
Старый 04.09.2018, 22:15   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
dynamicsnavax: Print a Sales Invoice via X++ in #MSDyn365FO
Источник: http://dynamicsnavax.blogspot.com/20...sdyn365fo.html
==============

Often you want to print a report via X++. One of the more common reports is the sales invoice.

Below is some code you could use to download a pdf copy. I am just picking the first invoice and printing to pdf.

Next few posts will be dependent on this. I will try to build up the scenario.



public static void printSalesInvoice()
{
CustInvoiceJour custInvoiceJour;

select firstonly custInvoiceJour
where custInvoiceJour.SalesId != '';

if (custInvoiceJour)
{
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();
}
}


Источник: http://dynamicsnavax.blogspot.com/20...sdyn365fo.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.