Hi,
I have implemented two different scenarios using PrintReportUtilities mixin methods. The first one (generateCardPrintForm) is to save the printable as an attachment in the Attachment and Note detail, and the other one (initCardPrintForms and preparePrintFormsMenuCollection) is used to filter the printables on the basis of lookup. The code is working fine but after refreshing the page.
The code used in OrderPageV2 is as follows
generateCardPrintForm: function(tag) {
// first get the printable being accessed
var printFormsCollection = this.get(this.moduleCardPrintFormsCollectionName),
printForm = printFormsCollection.get(tag);
var printableId = printForm.values.Id;
var orderId = this.get("Id");
ProcessModuleUtilities.executeProcess({
sysProcessId: '68880f82-xxxx-xxxx-xxxx-xxxxxfb532c2',
parameters: {
OrderId: orderId,
PrintableId: printableId
}
});
this.updateDetail({detail: "Files"});
this.callParent(arguments);
}
initQueryColumns: function(esq) {
this.callParent(arguments);
if (!esq.columns.contains("UsrDocumentRepositorySubtype")) {
esq.addColumn("UsrDocumentRepositorySubtype");
}
},
initCardPrintForms: function() {
this.callParent(arguments);
var printMenuItems = this.get(this.moduleCardPrintFormsCollectionName);
if (Ext.isEmpty(printMenuItems)) return;
printMenuItems.each(function(item) {
item.set("Visible", {bindTo: "getPrintMenuItemVisible"});
}, this);
},
initSectionPrintForms: function() {
this.callParent(arguments);
var printMenuItems = this.get(this.moduleSectionPrintFormsCollectionName);
if (Ext.isEmpty(printMenuItems)) return;
printMenuItems.each(function(item) {
item.set("Visible", {bindTo: "getPrintMenuItemVisible"});
}, this);
},
preparePrintFormsMenuCollection: function(printForms) {
printForms.eachKey(function(key, item) {
if (!item.get("Caption")) {
item.set("Caption", item.get("NonLocalizedCaption"));
}
item.set("Tag", key);
item.set("Visible", {bindTo: "getPrintMenuItemVisible"});
}, this);
},
// this is the function will determine if a printable is visible
// it is called for each printable and will return true/false to show or hide
getPrintMenuItemVisible: function(reportId) {
var type = this.get("Status") || { displayValue: "" },
printMenuItems = this.get(this.moduleCardPrintFormsCollectionName),
item = printMenuItems.find(reportId);
if (Ext.isEmpty(item)) return;
switch (item.get("Caption")) {
case "Order - Inprocess":
return type.displayValue === "3. In progress";
default:
return type.displayValue != "3. In progress";
}
}