Calling Sales Packing Slip Report through X++ Code
Hello Blogger Viewers,
Today, I am excited to share with you some X++ code that allows you to call the Sales Packing Slip report programmatically. This can be useful in scenarios where you need to automate the process of generating packing slip reports. Let's dive into the code!
SrsReportRunController ssrsController = new SrsReportRunController();
SalesPackingSlipContract salesPackingSlipContract = new SalesPackingSlipContract();
CustPackingSlipJour custPackingSlipJour;
SRSPrintDestinationSettings printerSettings;
select custPackingSlipJour where custPackingSlipJour.PackingSlipId == "200258-PAS-UK01";
// Define which report design to run.
ssrsController.parmReportName(ssrsReportStr(SalesPackingSlip, Report));
// Define how we want to execute the report (right now or batch style).
ssrsController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
// Hide the report dialog.
ssrsController.parmShowDialog(false);
// Set the record and table IDs for the report contract.
salesPackingSlipContract.parmRecordId(custPackingSlipJour.RecId);
salesPackingSlipContract.parmTableId(custPackingSlipJour.TableId);
// Link the contract to the controller so we know how to run the data provider.
ssrsController.parmReportContract().parmRdpContract(salesPackingSlipContract);
// Link the printer settings to the controller.
printerSettings = ssrsController.parmReportContract().parmPrintSettings();
// Set the print medium type to HTML and always overwrite the file if it exists.
printerSettings.printMediumType(SRSPrintMediumType::File);
printerSettings.fileFormat(SRSReportFileFormat::PDF);
printerSettings.overwriteFile(true);
printerSettings.fileName(@'C:\'+'PackingListReport'+custPackingSlipJour.PackingSlipId+'.pdf');
// Start the report execution.
ssrsController.startOperation();
After executing this code, you will be able to see the generated PDF file in your "Downloads" folder. This approach provides a convenient way to automate the process of generating Sales Packing Slip reports.
I hope you find this code snippet helpful for your X++ development. If you have any questions or suggestions, feel free to leave a comment below.
Happy coding!
No comments:
Post a Comment