in querytask, returnIdsOnly = true doesn't work

1212
3
12-09-2010 04:28 AM
joanvallespir
New Contributor
Good morning,

I'm experiencing an issue that could be a bug.

I'm using API 2.1 against an ArcGIs Server 10. I'd like to query a feature service and get the IDs resulting from a selection. I'm setting returnIdsOnly  parameter to true to retrieve an array with Ids but for some reason when I use it I get all the fields from the service as a featureset. I checked the resulting url, and (for my surprise) it doesn't contain the returnIdsOnly parameter :confused:, so it's not a problem related to AGS, so I guess it is a bug from the JS API.

This is the extract of code I'm using, and commented the workaround I'm using for the moment.

var QueryTask1 = new esri.tasks.QueryTask("http://server/arcgis/rest/services/../../FeatureServer/2");
var Query1 = new esri.tasks.Query();
Query1.where = "UPPER(field) like UPPER('%sometext%')";
Query1.returnIdsOnly = true;
//Query1.outFields = ['OBJECTID'];
QueryTask1.execute(Query1, showmeRecords);



Any similar experience?

Thank you
0 Kudos
3 Replies
TonyContreras
Occasional Contributor
I may be missing something, however the documentation does not show returnIdsOnly as a property of a query object. The workaround you have will probably be the best way available, though I did notice the executeForIds method that could work. There is little documentation on this, so it may or may not work like the execute method.

Class: Query
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/query.htm
0 Kudos
derekswingley1
Frequent Contributor
I think you're confusing the REST API with the JavaScript API. If you're using JS, use executeForIds().
0 Kudos
joanvallespir
New Contributor
Hi,

My fault, I confussed the REST and JS API. 😮 I thought you could add the same properties to the query like parameters in REST.  executeForIds worked fine!

Thanks for the quick replies!
0 Kudos