I am trying to select a group of features in an ESRI javascript API featureLayer by attribute. The call errors out. My code is as follows. Here is the layer definition:

    var fieldDefs = [{
        "name": "county",
        "type": "esriFieldTypeString",
        "alias": "county"
        "name": "pop",
        "type": "esriFieldTypeInteger",
        "alias": "pop"

        "name": "ObjectID",
        "alias": "ObjectID",
        "type": "esriFieldTypeOID"

    var featureCollection = {
              "layerDefinition": null,
              "featureSet": {
                "features": [],
                "geometryType": "esriGeometryPolygon";
    var featureCollection.layerDefinition = {
              "geometryType": "esriGeometryPolygon";,
              "objectIdField": "ObjectID",
              "drawingInfo": {
                "renderer": {
                  "type": "simple",
                  "symbol": symbol
              "fields": fieldDefs
     var featureLayer = new FeatureLayer(featureCollection, {
                  id: idString,
                  mode: FeatureLayer.MODE_SNAPSHOT,
                  fields: fieldDefs

I then populate the layer using applyEdits and later query the layer using this function:

queryCounty = function(county_name) {
            var query = new Query();
            query.where = "county = '" + county_name + "'";
            console.log("WHERE: " + "county = '" + county_name + "'");
            projectsOverlayMap.selectFeatures(query, FeatureLayer.SELECTION_NEW, function(results){

And calling it like this:


When I do that I get the following error:

"Error: FeatureLayer::selectFeatures - query contains one or more unsupported parameters

There are some decent on line examples of this function using geometry queries but none that I have found that use and attribute query. What am I missing?


2 Answers 2


Are you creating featurelayer by FeatureLayer(featureCollectionObject, options?)?

If yes there are some restriction for the featurelayer object. You cannot execute queries on such layers.

See the docs https://developers.arcgis.com/javascript/jsapi/featurelayer-amd.html#featurelayer2

  • The doc says "Does not support queries that need to be performed on the server" since I'm in snapshot mode, everything is persisting on the client, right? All the features are loaded in with attributes already, there is no serverside component. Nov 3, 2015 at 15:53
  • 1
    I thinks the query with where will work only with feature layer that has from server.Refer the thread geonet.esri.com/thread/14137 For testing try to execute the query with objectid
    – Shabeerali
    Nov 4, 2015 at 9:47

It's clunky but you can query on the extent of the map and then loop through the results to get the attributes you want. For example:

require(['esri/tasks/query', 'esri/layers/FeatureLayer'], function (Query, FeatureLayer) {
    var query = new Query();
    query.geometry = projectsOverlayMap.extent;
    featureLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (results) {
        for(var key in results) {
            if(results[key].attributes['county'] === county_name) {
                ... do something ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.