AnsweredAssumed Answered

FeatureLayer using FeatureCollection option ... query exception thrown

Question asked by dcastano on Jul 31, 2013
Latest reply on Nov 8, 2017 by ADongre1
Background:
- ArcGIS Server 10.1 sp1 using JS API 3.5
- Web Editing Application editing SDE Data (works fine .. for the most part)

Issue:
I have hit a roadblock when attempting to use a FeatureCollection to hold potential related attribute records.

Workflow:
Utilize the FeatureLayer with FeatureCollection option to create a temporary table to hold additional attributes for an edit featureLayer.  I have a feature class that I have served as a featureService in ArcGIS server. We would like to provide the option to allow the user to specify additional attributes stored in a seperate attribute table (no relationship class just simple PK-FK relationship). I have successfully used the ESRI AttributeInspector to manage the attribute tables and related tables. However, I was not fond of having an "Add" button to create force the users to create a new record in the related attribute table. I would prefer the record to be preloaded on the page and allow the user to Save the new record or changes back to the table.  Because of the way the AttributeInspector dijit works you MUST have records selected in order for them to be displayed in the UI.  This is simple to do with FeatureLayers that use a REST URL however, it appears that I am running into a roadblock when selecting records from a FeatureLayer with the FeatureCollection option.

Exception/Error:
I am getting the following exception thrown when attempting to retrieve/select the newly created record from the FeatureCollection.
"FeatureLayer::selectFeatures - query contains one or more unsupported parameters"

Supporting  Research Information:
ESRI Documentation: https://developers.arcgis.com/en/javascript/jsapi/featurelayer.html#featurelayer2
Does not support queries that need to be performed on the server, e.g. queries with a where clause or non-extent based spatial queries.


Forum Post: Clone a Server-based FeatureLayer to a local one?
http://forums.arcgis.com/threads/14665-clone-a-server-based-featurelayer-to-a-local-one
Dasa Paddock indicated that I should be able to use a query with objectIds paramater set.

1.) You can select features in a FeatureLayer that's using a FeatureCollection using an Extent geometry, objectIds or timeExtent.

2.) The AttributeInspector should work with a FeatureLayer that's using a FeatureCollection.

Dasa Paddock
Esri Flex Team


Forum Post: AttributeInspector requires a FeatureLayer when using graphics?
http://forums.arcgis.com/threads/65604-AttributeInspector-requires-a-FeatureLayer-when-using-graphics
You could create a feature collection based feature layer and use that with the AttributeInspector widget.
.. Kelly Hutchins (ESRI)


What does this all mean:
Exactly .. I am at a standstill. Initially, I had incorrectly used a where paramater with the query for the FeatureCollection but quickly remedied that. I am still getting the same error. Since this is a table with no geometry I do not have the option to select using a geometry paramater.  Any ideas?

Below is the code that I use to test this use case:

    //NEW code to test the creation of the FeatureCollection FeatureLayer    //I have tried diferent variations of this code and have simplified it down to this     var fieldsArray = [{ "name": "OBJECTID", "type": "esriFieldTypeOID", "alias": "OBJECTID" },       { "name": "GAZ_ID", "type": "esriFieldTypeInteger", "alias": "GAZ_ID" },       { "name": "GAZ_FEATUREHISTORY", "type": "esriFieldTypeString", "alias": "GAZ_FEATUREHISTORY", "length": 1073741822 },       { "name": "GAZ_FEATUREDESCRIPTION", "type": "esriFieldTypeString", "alias": "GAZ_FEATUREDESCRIPTION", "length": 1073741822}];     var layerDefinition = { "type": "Table", "fields": fieldsArray };     var featureCollection = { "layerDefinition": layerDefinition, featureSet: null };     _customFeatureLayer = new esri.layers.FeatureLayer(featureCollection, { "id": "myCustomClass", outFields: ["GAZ_ID", "GAZ_FEATUREHISTORY", "GAZ_FEATUREDESCRIPTION"] });     _customFeatureLayer.setEditable(true);     _map.addLayer(_customFeatureLayer);  //create the layerInfo to add to the attribute inspector var layerInfos = [{ 'featureLayer': _customFeatureLayer, 'fieldInfos': fieldInfos, 'isEditable': isTableEditable, 'showDeleteButton': false}]; var relTableAttInspector = new esri.dijit.AttributeInspector(           { 'layerInfos': layerInfos }, attributeDivId);  //at some point in the app prior to showing the attribut UI I attempt to create a new record in the FeatureCollection layer based on an existing attribute record from the FeatureLayer/table          _customFeatureLayer.applyEdits(results.selectionLayers[0].features, null, null, function (addResults) {           if (addResults[0].success) {             //var jsonObject = _customFeatureLayer.toJson();             //Now select the record so it shows up in the attribute UI             var query = new esri.tasks.Query();             query.returnGeometry = false;             query.objectIds = [addResults[0].objectId];             query.outFields = ["GAZ_ID", "GAZ_FEATUREHISTORY", "GAZ_FEATUREDESCRIPTION"];             _customFeatureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW, function (features) {               helperOperations.hideProcessingDialog();               showAttributePane();             }, function (e) {               processError("Error: " + e.message);             });           } else {             helperOperations.hideProcessingDialog();             showAttributePane();           }         }, function (error) {           processError("Error: unable to insert a record into the custom FeatureLayer");         }); 

Outcomes