I have a query that I believe I am setting up correctly, but maybe I'm missing a vital property. Does the where clause need to be set? I want to query all features, not a subset of them, so I don't really need a where restriction.
Every time I run this query it goes to the error callback where the message given is unhelpful.
printQLyr = new QueryTask("https://xxx/MapServer/3");
printQuery = new Query();
printQuery.returnGeometry = false;
printQuery.outFields = ["Name"];
printQLyr.on("complete", printQResults);
printQLyr.on("error", errorResults);
printQLyr.execute(printQuery);
function printQResults(featureSet) {
var resultFeatures = featureSet.features;
console.log(resultFeatures[0]);
}
function errorResults(message) {
console.log(message);
}
What I get back in the console is this:
Error at Object.A.m.load (https://js.arcgis.com/3.24/init.js:1028:392) at https://js.arcgis.com/3.24/init.js:87:429 at c (https://js.arcgis.com/3.24/init.js:103:393) at d (https://js.arcgis.com/3.24/init.js:103:182) at b.Deferred.resolve.callback (https://js.arcgis.com/3.24/init.js:105:10) at c (https://js.arcgis.com/3.24/init.js:104:96) at d (https://js.arcgis.com/3.24/init.js:103:182) at b.Deferred.resolve.callback (https://js.arcgis.com/3.24/init.js:105:10) at https://js.arcgis.com/3.24/init.js:92:118 at h (https://js.arcgis.com/3.24/init.js:107:277)
1 Answer 1
A Query will need a geometry, objectId, or a where clause to run. To select all features, use
printQLyr.where="1=1";
printQuery.where
and set it to something, but since I want to query all features, it doesn't make sense to set the where clause. I also see OBJECTID and Shape listed as fields under the "Fields" heading on my rest services page for the service, so I believe that means they're accessible.printQuery.objectIds
property... It just doesn't work when I have no filters set. I have also just tested this code snippet in the ArcGIS JS Sandbox and I receive the same error there as well.printQLyr.where "1=1"