There is a requirement in which I have to make printable visible on the basis of data in the connected object. I followed this article https://customerfx.com/article/showing-or-hiding-printables-based-on-a-value-for-the-selected-record-in-creatio/.
It is working fine on the combined mode in edit page and only showing printable which is matching with the condition, but the same is not reflecting on the separate mode in edit page and showing the complete list of printable.
Is there something which I am missing or any other workaround ?
Methods which I have added on section is :
initQueryColumns: function(esq) {
this.callParent(arguments);
if (!esq.columns.contains("Id")) {
esq.addColumn("Id");
}
},
GetDocumentCollection: function() {
var recObj = [];
var id = this.get("GridData").get(this.get("ActiveRow")).get("Id");
var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "Document" });
esq.addColumn("UsrDocumentName.Name");
esq.filters.add("UsrTransactions", Terrasoft.createColumnFilterWithParameter(
Terrasoft.ComparisonType.EQUAL, "UsrTransaction", id));
esq.getEntityCollection(function(result) {
var response = result.collection;
var hasRecord = (response.collection.length !== 0);
if(hasRecord) {
result.collection.each(function(item) {
recObj.push(item.get("UsrDocumentName.Name"));
});
}
this.set("DocumentCollection",recObj);
}, this);
},
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 Id = this.get("GridData").get(this.get("ActiveRow")).get("Id"),
printMenuItems = this.get(this.moduleCardPrintFormsCollectionName),
item = printMenuItems.find(reportId);
this.GetDocumentCollection();
if (Ext.isEmpty(item)) return;
var ReportName = item.get("Caption");
var DocCollection = this.get("DocumentCollection");
if(DocCollection === undefined){
return false;
}
else{
if(DocCollection.includes(ReportName)){return true;}
else{return false;}
}
}
Methods which I have added on edit page is :
GetDocumentCollection: function() {
var recObj = [];
var id = this.get("Id");
var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "Document" });
esq.addColumn("UsrDocumentName.Name");
esq.filters.add("UsrTransactions", Terrasoft.createColumnFilterWithParameter(
Terrasoft.ComparisonType.EQUAL, "UsrTransaction", id));
esq.getEntityCollection(function(result) {
var response = result.collection;
var hasRecord = (response.collection.length !== 0);
if(hasRecord) {
result.collection.each(function(item) {
recObj.push(item.get("UsrDocumentName.Name"));
});
}
this.set("DocumentCollection",recObj);
}, this);
},
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) {
//this.GetDocumentCollection();
var Id = this.get("Id"),
printMenuItems = this.get(this.moduleCardPrintFormsCollectionName),
item = printMenuItems.find(reportId);
if (Ext.isEmpty(item)) return;
this.GetDocumentCollection();
var ReportName = item.get("Caption");
var DocCollection = this.get("DocumentCollection");
if(DocCollection === undefined){
return false;
}
else{
if(DocCollection.includes(ReportName)){return true;}
else{return false;}
}
}