Hello everyone! While I was working with Docentric reports, some doubts have arisen.
Customer requirement is to print a delivery note or both a delivery note and a proforma invoice, based on the value of the mode of delivery of the shipment (condition configured through print management setup).
Our idea is to print two different reports, based on the value of mode of delivery:
- The first report contains only the delivery note.
- The second one collapses in a single document both delivery note and pro forma invoice.
My question is: is it possible to create through Docentric a single report that contains both delivery note and pro forma invoice for a shipment?
Thanks for the help,
It is possible through Docentric. I assume that you want to include the appropriate delivery note report when printing the proforma sales invoice. Here are suggested steps for doing that:
- Save the delivery note report (in PDF format) in the attachment of the related sales order. You can add this manually or use the Docentric feature save to attachment under the file print destination settings. For more information on printing reports in attachments see this link
- Subscribe to delegate generateReportContent which is executed whenever the report content is generated using any Docentric print destination, no matter if you are using a SSRS report design or a Docentric template. Here implement your logic for merging proforma invoice as it is shown in this article (topic “the coding part”).
It is possible to skip step 1 (save delivery note report to attachments). This way, in the delegate method, you need to run a delivery note report via code and get a container of the report. Next, merge it with the proforma invoice. Here is a POC showing the merge of sales invoice and project invoice.
[SubscribesTo(classStr(DocReportRunDelegates), delegateStr(DocReportRunDelegates, generateReportContent))]
public static void DocReportRunDelegates_generateReportContent(DocPrintReportSettings _printReportSettings,
DocPrintedReport _printedReport, DocEventHandlerResult _result)
// If this is not the SalesInvoice report, return.
if (_printReportSettings.parmReportId() != ssrsReportStr(SalesInvoice, Report))
// If report output format is not PDF, return.
if (_printedReport.outputFileFormat() != DocFileFormat::PDF)
//if (some condition) -> generate PSAProjInvoice
container psaProjInvoiceContainer = DocMergeSalesInvoiceWithPSAProjInvoice::printPSAProjInvoiceReportToContainer(_printReportSettings);
// Merge Sales Invoice and PSA Proj Invoice.
System.Byte additionalReportPSAProjInvoice = DocGlobalHelper::convertContainerToBytes(psaProjInvoiceContainer);
System.Byte mainReportSalesInvoice = _printedReport.getReportContentByteArray();
List mergingReportsList = new List(Types::AnyType);
// Create the merged PDF file from the document contents saved in the list
using (System.IO.MemoryStream mergedPDFStream = DocDocumentHelper::mergePdfDocuments(mergingReportsList))
// Uncomment next line to download the resulting PDF file to the browser
public static container printPSAProjInvoiceReportToContainer(DocPrintReportSettings _printReportSettings)
controller = new PSAProjAndContractInvoiceController();
args = new Args();
// Use _printReportSettings.parmArchiveContract() to fetch the corresponding project invoice.
projInvoiceJour = ProjInvoiceJour::findRecId(5637146255);
DocSrsReportGenerator reportGenerator = new DocSrsReportGenerator(controller);
// TODO: If you want to print PSAProjInvoice using SSRS Report design, uncomment the following line.
// TODO: Set settings for generation of the Docentric report using the default Docentric template or provide a specific one.
PSAProjPrintInvoice psaProjPrintInvoice = PSAProjPrintInvoice::construct();
// Call the initArgs() method via reflection, because it's a protected method.
new DictClass(classNum(PSAProjAndContractInvoiceController)).callObject(methodStr(PSAProjAndContractInvoiceController, initArgs), controller, args);
container generatedInvoice = reportGenerator.generateReport();
Please let us know if this helps.