Tuesday, February 4, 2014

Printing Purchase Order to file by code

Hi

Below the code for generate a file ( PDF, Xlsx, etc. ) from a Purchase Order Report.

SrsReportRunController controller = new SrsReportRunController();
PurchPurchaseOrderContract rdpContract = new PurchPurchaseOrderContract();
SRSPrintDestinationSettings settings;

// Define report and report design to use
controller.parmReportName(ssrsReportStr(PurchPurchaseOrder, Report));

// Use execution mode appropriate to your situation
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);

// Suppress report dialog
controller.parmShowDialog(false);

// Explicitly provide all required parameters
rdpContract.parmRecordId( VendPurchOrderJour::findRecId(5637146077).RecId );
controller.parmReportContract().parmRdpContract(rdpContract);

// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.fileName(@'\\UNCPATH\test.pdf');

// Execute the report
controller.startOperation();

Enjoy !
 

3 comments:

Vitaliy Glushchenko said...

rdpContract.parmRecordId( VendPurchOrderJour::findRecId(5637146077).RecId );

Why we need do this action?
Find record by RecId, and get from this record RecId ...

Denis Macchinetti said...

Hi

This is an example.
The goal is to provide the recid of the master record.

Sharon Stone said...

No wonder why you get so many feedbacks Every Door Direct Mail postcard printing miami