Query task / Find task Objectid conflict

2000
3
08-22-2012 01:31 PM
AllisonAnderson
New Contributor III
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...
0 Kudos
3 Replies
EmilyLaMunyon
Occasional Contributor
Hi,

I am having the same issue. Did you ever find a solution to this?

Thanks!
0 Kudos
DavidMcGill
New Contributor
http://jsfiddle.net/M4fAg/

jsfiddle.net needs to be set to OnLoad and jQuery 1.8.2

click a point on the map and it display the results in the datagrid.
type in Katz and click the search button and it displays the results in the datagrid.
0 Kudos
AdrianMarsden
Occasional Contributor III
I did read somewhere here that you don't actually need an identifier, if you leave it out one is generated.  I was having similar issues with using fields I was sure had unique values.  I then left the identifier out of the definition bit and everything worked.

ACM
0 Kudos