I am trying to filter the list of products shown in the Application page, based on the field Segment. The field segment is part of the object FZVwActiveProduct (it represents a view in db). This object has the following fields: FZId (GUID), FZOpportunityConditionName (Text),
FZProduct (Lookup -> Product), FZProductCategory(Lookup -> ProductCategory), FZProductType (Lookup -> ProductType), FZSegmentation (Lookup -> Segment).
The filter used for Products in BaseFinApplicationPage uses the object VwFinActiveProduct (it represents a view in db), which has the following fields: Name (Text), OpportunityCondition(Lookup -> OpportunityCondition), Product(Lookup -> Product).
The original creatio function used for filtering is:
getActiveProductLookupFilter: function() {
var filters = this.Terrasoft.createFilterGroup();
var productType = this.get("ProductType");
var productCategory = this.get("ProductCategory");
if (this.Ext.isObject(productType)) {
var productTypeFilter = this.Terrasoft.createColumnFilterWithParameter(this.Terrasoft.ComparisonType.EQUAL,
"Product.Type", productType.value);
filters.add("TypeFilter", productTypeFilter);
}
if (this.Ext.isObject(productCategory)) {
var productCategoryFilter = this.Terrasoft.createColumnFilterWithParameter(this.Terrasoft.ComparisonType.EQUAL,
"Product.Category", productCategory.value);
filters.add("CategoryFilter", productCategoryFilter);
}
var productStatusFilter = this.Terrasoft.createColumnFilterWithParameter(this.Terrasoft.ComparisonType.EQUAL,
"Product.ProductStatus", BaseFinanceConstants.ProductStatus.IsActual);
filters.add("StatusFilter", productStatusFilter);
return filters;
}
I have overriden it to use the foloowing filtering, but it does not provide any filtering and it throws the error:
{
"errorCode": "ItemNotFoundException",
"message": "Column by path [FZVwActiveProduct:FZProduct].Id not found in schema VwFinActiveProduct.",
"errors": []
}
getActiveProductLookupFilter: function() {
var borrower = this.get("Borrower");
var filters = this.Ext.create("Terrasoft.FilterGroup");
// Retrieve the SegmentationId from the borrower
var segmentationId = borrower.FZSegmentationId;
var contactFilter = this.Ext.create("Terrasoft.FilterGroup");
var contactLookupFilter = Terrasoft.createExistsFilter("[FZVwActiveProduct:FZProduct].Id");
//Application Filter
contactLookupFilter.subFilters.addItem(Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.EQUAL, "FZSegmentation", segmentationId));
contactFilter.addItem(contactLookupFilter);
return contactFilter;
// Create EXISTS filter for FZVwActiveProduct
var existsFilter = Terrasoft.createExistsFilter("[FZVwActiveProduct:FZProduct].Id");
// Filter to match Product in VwFinActiveProduct with FZProduct in FZVwActiveProduct
existsFilter.subFilters.addItem(
Terrasoft.createColumnFilterWithParameter(
Terrasoft.ComparisonType.EQUAL,
"FZProduct",
"Product"
)
);
// Filter to match SegmentationId in FZVwActiveProduct
existsFilter.subFilters.addItem(
Terrasoft.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "[FZVwActiveProduct:FZProduct].FZSegmentation", segmentationId)
);
// Add the EXISTS filter to the filter group
filters.addItem(existsFilter);
return filters;
}
Like
Hello Alba,
Such an error usually occurs in the construction of the filter, causing an incorrect database query.Value [FZVwActiveProduct:FZProduct].Id should be defined in another way. Please, debug your code to analyze which value may be passed to existsFilter and contactLookupFilter.
Additionally, I've found a good article that explains how to build the right filter conditions using the usual filters in Creatio.