Hi, we try to run simple QueryTask on large (1.5 million features) map service layer:
var queryTask = new QueryTask("someURL/arcgis/rest/services/Polygons2/MapServer/0");
var query = new Query();
query.returnGeometry = true;
query.outFields = ["Name1,Name2"];
query.where = "SomeID = 12345";
queryTask.execute(query, _showResults, _displayError);
_showResults = function (features) {
selectedGraphics.clear();
for (var i = 0; i < features.length; i++) {
var feature = features;
feature.symbol = HighlightSymbol;
selectedGraphics.add(feature);
}
_displayError = function (error) {
console.log(error);
alert("Error");
};
We have the error:
Error: Failed to execute query.
at Object.g.load (https://js.arcgis.com/3.17/init.js:857:426)
at https://js.arcgis.com/3.17/init.js:87:450
at c (https://js.arcgis.com/3.17/init.js:103:393)
at d (https://js.arcgis.com/3.17/init.js:103:182)
at b.Deferred.resolve.callback (https://js.arcgis.com/3.17/init.js:105:10)
at c (https://js.arcgis.com/3.17/init.js:104:96)
at d (https://js.arcgis.com/3.17/init.js:103:182)
at b.Deferred.resolve.callback (https://js.arcgis.com/3.17/init.js:105:10)
at https://js.arcgis.com/3.17/init.js:92:118
at h (https://js.arcgis.com/3.17/init.js:107:279)
Please help to understand/fix the error.
Solved! Go to Solution.
First thing I would do is verify that your query works just using the rest end point for the map service.
First thing I would do is verify that your query works just using the rest end point for the map service.
Robert, thank you.
I did.
Seems to be syntax error in the query.where.
Is the field you are querying a string or numeric?
It is string.
The solution:
query.where = "SomeID = '12345'";
Great.
Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.