Question

Executing ESQ, result always is not defined

Good day.

I'm trying use Entity schema query for get the records from the database, but I when use the following code the result is zero, my code is following

showWorksDoneInfo: function() {

                // Receiving the order end date.

                //var dueDate = this.get("UsrFechaCompra");

                // Calling the standard system method for the data window display.

                //this.showInformationDialog(UsrFechaCompra);

                var worksDonecount="0";

                var esq = this.Ext.create(Terrasoft.EntitySchemaQuery, {

                    rootSchemaName: "UsrWorksDone"

                });

                

                //var car = this.get("Id");

                //esq.addColumn(car);

                

                esq.addAggregationSchemaColumn("Id", Terrasoft.AggregationType.COUNT, "WorksDoneCount", 

                Terrasoft.AggregationEvalType.ALL);

                

                //Filtro por Id de carro en WorksDone

                //var idCar = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, 

                //"UsrLookupCarWorkId", this.get("UsrLookupCarWorkId"));

                

                //Agrego filtros a la consulta

                //esq.filters.add("idCar", idCar);

                

                //esq.getEntity(function(result)

                //{

                    //worksDonecount = result.entity.get("WorksDoneCount");

                //});

            

                this.showInformationDialog(worksDonecount);

            },

 

Result, is always "result is not defined"

Like 0

Like

2 comments

Please catch the request with fiddler and check if the filtration in the request matches to your needs. 

https://www.telerik.com/fiddler

Then please deploy the application locally and use SQL server profiler in order to catch the request that takes the data from the database. 

https://academy.bpmonline.com/documents/administration/7-14/installing-bpmonline?document=enterprise

This way you'll be able to find what's wrong. 

Calling esq.getEntity requires an ID for the entity record you wish to get, this is provided as the first parameter to getEntity. Like this:

esq.getEntity(someIdValue, function(result) {
    //...
}, this);

Otherwise, you can use getEntityCollection and not specify a specific record. This will return just the records that match your query. This would better fit what you are needing, even though you're getting an aggregate, your collection will just have the one row:

esq.getEntityCollection(function(result) {
    //...
}, this);

Ryan

Show all comments