I need to be able to query a mapservice that contains a number of different OBJECTIDs. In regular SQL I would say "(OBJECTID = 123) OR (OBJECTID =456). When I put this in my where clause of the Javascript API, I get an error that the where clause is an invalid parameter:
var query3 = new Query(); query3.returnGeometry = true; query3.where = "(OBJECTID=123) OR (OBJECTID=456)query3.outSpatialReference = { "wkid": 102100 };
I need the geometry.
I have also tried where="OBJECTID in (123,456)" and I get the same error message. This is the result of a vendor limiting a query to 100 features unless a "resultOffset" that returns only IDs is used, so I need to first pull the 100 IDs and then I have to loop through to create another query that will pull the features that have those 100 IDs. It seems so simple, but I can't seem to do it! Please help!
Solved! Go to Solution.
Sounds like they are doing more behind the scenes to limit queries.
I T,
The "OBJECTID IN (123, 456)" should be a valid where statement. Are you sure that OBJECTID is your layers actual Object Id field?
Yes, this is really confusing me. If I change the query to: query3.where = "OBJECTID in (123)";
it still fails. But, if I change it to: query3.where = "OBJECTID = 123"; it works!
I have query3.returnGeometry = true; and query3.outFields = ["OBJECTID"] .Does this somehow affect the where clause? Are there limitations on queries you can pull on the OBJECTID? Is there a specific order that I need to declare the parameters? This is the URL that is built:
This is the actual message returned:
{"error": {"message": "Invalid or missing input parameters.", "code": 400, "details": ["Invalid where clause specified"]}}
Sounds like they are doing more behind the scenes to limit queries.