JavascriptAPI OR in query

1465
3
Jump to solution
06-28-2019 04:10 PM
LisaT
by
Occasional Contributor III

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!

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Sounds like they are doing more behind the scenes to limit queries.

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

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?

0 Kudos
LisaT
by
Occasional Contributor III

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:

https://vendorwebsite.com/api/rest_services/client=ABC123/Parcels/MapServer/0/query?f=json&where=OBJ...

This is the actual message returned:

{"error": {"message""Invalid or missing input parameters.""code": 400, "details": ["Invalid where clause specified"]}}
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Sounds like they are doing more behind the scenes to limit queries.