cpher

FeatureLayer selectFeatures issue on subsequent queries

Discussion created by cpher on Nov 29, 2011
Latest reply on Dec 1, 2011 by cpher
I'm having an issue with the featureLayer.selectFeatures method in the API. I'm using v2.5 compact
On the first query attempt, everything works fine:
- Not using a "where" statement
- objectIds set to valid value
- feature is successfully returned.

However, on subsequent queries (using the exact same code) here are my results:
- A "where" statement is added even though I didn't specify one, with the OBJECTID value from the first feature that I queried. It's almost as if the previous query result's OBJECTID is being cached.
- Feature is not returned because the OBJECTID value is from the previous query, not from the new query.

My query object (esri.tasks.Query) is scoped locally to the method, so I know it's not a global variable issue. But, for some reason, a "where" statement is added automatically when the HTTP request is made (verified by inspecting the request in Fiddler). I've even manually set the query.where statement = null but this has no effect. The where statement is added anyway.

I've also manually created a where statement that includes the new OBJECTID value (instead of specifying in the query.ObjectIds param), but the HTTP request includes the value from the previous query anyway. Ex: "where OBJECTID = 1 and ID= 3 and OBJECTID=3. So, two OBJECTID values are added.

Here is my method's code:
function searchForStructure(feature_object_ids) {
    var feature_objectid_string = feature_object_ids.join(",");
    var query = new esri.tasks.Query();
    query.outSpatialReference = { "wkid": 102100 };
    query.returnGeometry = true;
    query.outFields = ["*"];
    query.where = null;
    query.objectIds = [feature_id_string];
    structuresLayer.clearSelection();
    structuresLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
}


Has anyone else noticed this behavior?
Thanks,
Chris

Outcomes