printable filter doesn't apply when record page is refreshed

Hello creatio team, 

 

I have successfully set up the printables show/hide feature based on the value from field(Currency). But it only works when record is opened from section page or navigated from other page. It doesn't work if I refresh the record page. (I don't have any section printable so only focusing on edit page printables. )

 

 I have tried adding the preparePrintFormsMenuCollection() on the edit page and apply the filter there so it could work on refresh. But the value of the currency field coming as undefined so I can apply static filter and that worked on refresh but if I want to add condition based on currency to show and hide I can't do it.

 

 

My code on Edit page: 

 

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);

},

 

getPrintMenuItemVisible: function(reportId) {

var currentCurrency = this.get("UsrCurrency") || { displayValue: "" };

var        printMenuItems = this.get(this.moduleCardPrintFormsCollectionName),

item = printMenuItems.find(reportId);

 

if (Ext.isEmpty(item)) {

return false; // Ensure a boolean return

}        

                                 var caption = item.get("Caption") || "";

 

var isUsCurrency = currentCurrency.displayValue === "US";

 

var containsUs = caption.includes("-US");

 

return isUsCurrency === containsUs;

 

}, 

 

 

My code on section page: 

 

initQueryColumns: function(esq) {

this.callParent(arguments);

 

if (!esq.columns.contains("UsrCurrency")) {

esq.addColumn("UsrCurrency");

}

},

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);

},

getPrintMenuItemVisible: function(reportId) {

if (Ext.isEmpty(this.get("ActiveRow"))) return true;

 

var currentCurrency = this.get("GridData").get(this.get("ActiveRow")).get("UsrCurrency") || { displayValue: "" };

var        printMenuItems = this.get(this.moduleCardPrintFormsCollectionName);

var        item = printMenuItems.find(reportId);

 

if (Ext.isEmpty(item)) return;

var caption = item.get("Caption") || "";

 

var isUsCurrency = currentCurrency.displayValue === "US";

 

var containsUs = caption.includes("-US");

 

return isUsCurrency === containsUs;

},

 

 

 

I have tried adding in the  preparePrintFormsMenuCollection()

 

 

preparePrintFormsMenuCollection: function(printForms) {

printForms.eachKey(function (key, item) {

if (!item.get("Caption")) {

item.set("Caption", item.get("NonLocalizedCaption"));

}

item.set("Tag", key);

if (item.get("TypeColumnValue")) {

item.set("Visible", { bindTo: "getPrintMenuItemVisible" });

}

 

var currentCurrency = this.get("UsrCurrency");

console.log("## currentCurrency", currentCurrency);

 

    var caption = item.get("Caption") || "";

If(currentCurrency.displayValue === "US"){

item.set("Visible", caption.includes("-US"));

}

}, this);

}

Like 0

Like

0 comments
Show all comments