allisonlbanderson

Query task / Find task Objectid conflict

Discussion created by allisonlbanderson on Aug 22, 2012
Latest reply on Nov 6, 2012 by amarsden
I have both a query task and a find task in my app but there seems to be something funny going on. 

If they both use the objectid as their identifier the query result is fine and populates the datagrid, the find task returns the graphic, but cannot populate my datagrid.  I get "Sorry, an error occurred" instead.

            function identifyExtent(extent) {

                //function identifyExtent sets up the selection tool and sends the query results to a datagrid
                drawToolbar.deactivate();

                //select features within the draw extent
                var query = new esri.tasks.Query();
                query.geometry = extent;
                aerialsLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW, function (features, selectionMethod) {
                    //adds selected features to the grid
                    var items = dojo.map(features, function (feature) {
                        return feature.attributes;
                    });
                    var data = {
                        identifier: "objectid",
                        items: items
                    };
                    var store = new dojo.data.ItemFileReadStore({
                        data: data
                    });
                    grid.setStore(store);
                    grid.setSortIndex(3);
                });
            }


and
            function showResults(results) {
                //This function works with an array of FindResult that the task returns
    
    clearGrid();
                var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([98,194,204]), 2), new dojo.Color([98,194,204,0.5]));

                //create array of attributes
                var items = dojo.map(results, function (result) {
                var graphic = result.feature;
                //var resultTemplate = new esri.InfoTemplate("<b>Project Name</b>: ${objectid}");
                    graphic.setSymbol(symbol);
                    map.graphics.add(graphic);
                    
                    return result.feature.attributes;
                    map.graphics.setInfoTemplate(resultTemplate);
                });

                //Create data object to be used in store
                var data = {
                    identifier: "objectid",
                    items: items
                };


                //Create data store and bind to grid.
                var store = new dojo.data.ItemFileReadStore({
                    data: data
                });

                grid.setStore(store);
                grid.setSortIndex(3);

            }



If I switch the identifier of the find task to another field, the task works, but the objectid is not returned to the datagrid, which is problematic because I have that field formatted to zoom to the feature.  Is there some sort of conflict between the two tasks utilizing the same identifier?

I should also add, that I have gotten it to work using the same identifier with a smaller subset of data, about 15 features.  This is moving to production with a larger set of data (400 features).  Is there a limit to the number of features in a find task?  I would hope it's higher than 400...

Outcomes