'where' parameter is invalid on query on feature layer

4386
8
09-10-2013 05:54 PM
PeterHudson
New Contributor
Hi everyone,
it has been a week that I have this problem.
I haven't changed anything on my code but 1 week ago I received a "'where' parameter is invalid" error when this query is executed on a feature service (hosted on Arcgis online):

var statDef = new StatisticDefinition();
  statDef.statisticType = "sum";
  statDef.onStatisticField = "Area";
  statDef.outStatisticFieldName = "Tot Area";
  
  var query = new Query();
  query.returnGeometry = false;
  query.where = "Area>0";
  query.outFields = ["Area"];
  query.outStatistics = [ statDef ];
  query.groupByFieldsForStatistics = ["YearEstabl", "TypeName"];
  query.orderByFields = ["YearEstabl", "TypeName"];
  
  var qt = new QueryTask("http://services1.arcgis.com/Mpa25zPNMAT08GQg/ArcGIS/rest/services/AllPropertiesEstablished/FeatureServer/0");
  qt.execute(query, function(result){
                   ...
  }
  });


I am referencing to //js.arcgis.com/3.6/

Any ideas?

Thanks in advance!
0 Kudos
8 Replies
VinayBansal
Occasional Contributor II
Hi,

I tried running the query using Rest API interface using
http://services1.arcgis.com/Mpa25zPNMAT08GQg/ArcGIS/rest/services/AllPropertiesEstablished/FeatureSe... in browser.
Even there where parameter is giving same error you are getting in your code when using with outStatistics

Don't know why it is not accepting the where clause, as Rest API documentation http://resources.arcgis.com/en/help/rest/apiref/ says that
When using outStatistics the only other parameters that will be used are groupByFieldsForStatistics, orderByFields, text, time, and where.
0 Kudos
JasonZou
Occasional Contributor III
To use outStatistics, the layer has to support Statistics. The layer you are querying does not support it. Here is one feature layer that supports it. Look for Supports Statistics: entry.
0 Kudos
VinayBansal
Occasional Contributor II
Hi Jason,

But the statistics is working on this layer......if we run query without passing the where clause......
Check the attachment.......
0 Kudos
JasonZou
Occasional Contributor III
It seems like spaces are not welcomed for outStatisticFieldName.

Try to change:
statDef.outStatisticFieldName = "Tot Area";


To:
statDef.outStatisticFieldName = "TotArea";
0 Kudos
JasonZou
Occasional Contributor III
Interesting. This sample does use where clause for the statistical calculation, and it works. The main difference I can tell is the sample uses a feature layer that supports statistics, while rokitmaps uses a feature service.
0 Kudos
VinayBansal
Occasional Contributor II
Interesting. This sample does use where clause for the statistical calculation, and it works. The main difference I can tell is the sample uses a feature layer that supports statistics, while rokitmaps uses a feature service.

Yes Jason, not seeing any other difference, other than Supports statistics......
So rokitmaps, atleast you can give it a try by setting SupportsStatistics true for the layer.....
0 Kudos
PeterHudson
New Contributor
Yes Jason, not seeing any other difference, other than Supports statistics......
So rokitmaps, atleast you can give it a try by setting SupportsStatistics true for the layer.....


From here I can see that "supportsStatistics" : true. In fact it worked before.

The query works without the StatisticDefinition. Anyway, I had to rewrite my code and do the group by manually... 😞
0 Kudos
VinayBansal
Occasional Contributor II
You can try by accessing the mapservice as MapServer instead of FeatureServer.....
0 Kudos