Select to view content in your preferred language

query class outFields can only return all fields from hosted feature service

7634
5
Jump to solution
04-11-2014 12:14 PM
JohnBigham
Deactivated User
We have been trying to access several attribute fields using the query class.  It works as expected using a layer from our own ArcGIS 10.1 server.  However, when trying to access from an ArcGIS Online hosted feature service it can only access all the fields.  If you try to specify only several fields it does not return anything. 

//this works query.outFields = ["*"];  // this does not work query.outFields = ["NAME", "STATE_ABBR", "POP04"];


Has anyone else experienced this issue?  It appears to possibly be a bug using the Javascript API to query the hosted feature services.

Thanks.

John
0 Kudos
1 Solution

Accepted Solutions
JonathanUihlein
Esri Regular Contributor
0 Kudos
5 Replies
JonathanUihlein
Esri Regular Contributor
Hey John,

If you have time, could you create a sample of your issue using jsfiddle.net?

I'd love to take a look.

In the meantime, I found this sample that sets the outFields directly and it seems to work as expected.

https://developers.arcgis.com/javascript/jssamples/fl_dgrid.html

If you change outFields to ["*"], you will see there are a lot more fields than when using:

outFields = ["OBJECTID", "NAME", "MEDNW_CY"];
0 Kudos
JeffPace
MVP Alum
I have seen this before if you specify a field name that does not exist.

Double check your rest endpoint and make sure the field names you require are accurate
0 Kudos
JohnBigham
Deactivated User
Hi.  Thanks for the responses. 

One thing I did not realize when I posted was that I created a Map Service on ArcGIS Server, not a feature service.  The example you posted Jon is also using a map service.  Those both work.  However, when we tried to hit a Feature Service on ArcGIS server or ArcGIS Online we were not able to retrieve the specific outfields. 

Here's a basic example in jsfiddle using an ArcGIS Online feature service:

http://jsfiddle.net/tE4A3/

In that example you can see we query for a single field to get the attribute and there is no attribute returned.  You can see that in the console.  So we still see the issue for feature services.

Thanks.

John
0 Kudos
JonathanUihlein
Esri Regular Contributor
This is working for me:

http://jsfiddle.net/tE4A3/4/

This sample uses: ["*"]

http://jsfiddle.net/tE4A3/5/
0 Kudos
JohnBigham
Deactivated User
Hi.

Thanks for the examples.  The first sample did help us to get things working by waiting until the layer loads and then specifying all poential outFields when the featureLayer was constructed since those override the query outFields later. 

However, I guess ultimately what we were looking for was a way for the query.outFields to also be used for restricting the fields so that the returned featureSet can be minimized for multiple queries with different field requests.  So in your second example, be able to specify perhaps five fields when the featureLayer was constructed and then only query for 1 or 2 fields in the query.outFields statement.  That doesn't seem to be possible right now though.

Thanks.
0 Kudos