Error at lookup filtration

Hello community!


I am trying to filter some values of a lookup, and this is the error i get in the console

Does anyone know how can I fix it, or where it's coming from?

Thank you.

Like 0



Hi Nicolaiciuc,


Can you share the code that you have implemented to filter?





Sourav Kumar Samal,

Hello, here is my code:


"LbkNewSearchCollateralsInOpp": {
                "dataValueType": Terrasoft.DataValueType.LOOKUP,
                "lookupListConfig": {
                    "filters": [
                        function() {                        
                            // adding the filter to the detail
                            var parentProduct = this.get("OpportunityProductInterest");
                            var filterGroup = Ext.create("Terrasoft.FilterGroup");
                            if (parentProduct) {
                                var parentProductId = parentProduct.value;
                                var subFilters = this.Terrasoft.createFilterGroup();
                                var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                                    rootSchemaName: "OpportunityProductInterest"
                                esq.getEntity(parentProductId, function(result) {
                                if (result.success) {
                                    var opportunityId = result.entity.get("Opportunity").Id; 
                                    var newesq = Ext.create("Terrasoft.EntitySchemaQuery", {
                                        rootSchemaName: "LbkProductCollateralTypes"
                                    var esqFilter = newesq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Opportunity.Id", opportunityId);
                                    newesq.getEntityCollection(function (newresult) {
                                        if (newresult.success) {
                                                newresult.collection.each(function (item) {
                                                    var defaultRemainingInBaseCollateral = item.values.LbkProductCollateralTypesRemainingAllocation;
                                    Terrasoft.ComparisonType.GREATER, defaultRemainingInBaseCollateral, 0));
                                filterGroup.add("Remaining value greater than 0",
                                    }, this);
                            }, this);
                            return filterGroup;

Nicolaiciuc Maria,

This won't work. The ESQ query you are attempting is asyncronous, meaning the filter function will return/complete before the ESQ has completed. You'll need to split this into two parts. One part will retrieve the values from LbkProductCollateralTypes and store them in an attribute on the page. This would be called in the onEntityInitialized. The idea is that you're pre-fetching the values from that object beforehand. Then, in the filter function, you'd be reading that attribute to construct and return the FilterGroup as needed, all synchronous since you've already pre-fetched the LbkProductCollateralTypes values in the onEntityInitialized. The filter function won't get called until the lookup is used, so the code in the onEntityInitialized will have completed before then and the LbkProductCollateralTypes values in the attribute will be available by then. Does that make sense? 


Show all comments