Article
Configuring the printing of several different printing forms at the click of a button
03:55 May 03, 2018
This article explains how to bind two different printables together and use one click to print.
Case description:
For example, the first part of the printable should be generated as a word file and the second printable should be generated as a PDF file. It contains information from the opportunity, which the users are not allowed to change it.
Algorithm of realization:
- We need to bind two printing forms. You should create an object that will contain links to the root printable form, and additional printable.
- You should to create and configure two printables or use existing. You should create a lookup for printables binding and bind two printables, which will be printed together.
- You should create client replacing module for "OpportunityPageV2" and "OpportunitySectionV2" from NUI package
-
Insert following code in OportunityPageV2 and OpportunitySectionV2
define("OpportunitySectionV2", [], function() { return { entitySchemaName: "Opportunity", methods: { generatePrintForm: function(printForm) { this.callParent(arguments); this.generateAdditionalReports(printForm.getTemplateId(), this.getPrintRecordId() || Terrasoft.GUID_EMPTY); }, getAdditionalReportsESQ: function(mainReportId) { var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "GlbAdditionalReport" }); esq.addColumn("GlbAdditReport.Id", "AdditionalReportId"); esq.addColumn("GlbAdditReport.ConvertInPDF", "CToPdf"); esq.filters.add("OpportunityFilter", this.Terrasoft.createColumnFilterWithParameter( this.Terrasoft.ComparisonType.EQUAL, "GlbMainReport", mainReportId)); return esq; }, generateAdditionalReports: function(rootReportId, recordId) { this.showBodyMask(); var esq = this.getAdditionalReportsESQ(rootReportId); esq.getEntityCollection(function(result) { if (result.success && result.collection.getCount() > 0) { result.collection.each(function(item) { var data = { templateId: item.get("AdditionalReportId"), convertInPDF: item.get("ConvertInPDF"), recordId: recordId || Terrasoft.GUID_EMPTY }; var serviceConfig = { serviceName: "ReportService", methodName: "CreateReport", data: data, timeout: 20 * 60 * 1000 }; var callback = function(response) { var key = response.CreateReportResult; this.downloadReport(item.get("AdditionalReportId"), key); }; this.callService(serviceConfig, function(response) { callback.call(this, response); }, this); }, this); } else { return; } }, this); this.hideBodyMask(); } } }; });
!!! IMPORTANT. You should allow multiply download files in your browser.
17:39 Jul 30, 2020
Dear,
The provided code works properly. Please don’t forget to replace the “&&” symbols with “&&” symbols and the “>” symbols with the “>” symbol.
Best regards,
Norton
Show all comments