ArcGIS 10.4 QueryTask outfields issue

881
2
10-20-2017 10:52 AM
CoreyMoten
New Contributor

Hello,

I am experiencing a strange issue with the outfields attribute of the Query class in the JS API. So I have a 10.4.1 ArcGIS server instance with a published map service running. The map service data source is an SDE instance backed by SQL Server. I am trying to query this map service to retrieve all the distinct values for a particular field. So my query looks like the following:

var query = new esri.tasks.Query();

query.returnGeometry = false;

query.returnDistinctValues = true;

query.outFields = [<field-name-is-too-long-I-guess>];

query.where = "OBJECTID >= 0";

The field name that I am querying in the outFields attribute is about 25 characters long. When I attempt to execute this query with an esri.tasks.QueryTask instance, the query fails because the field name in outFields is being truncated to 22 characters before it gets to the database. So the field name being queried in the database becomes 'field-name-is-too-long' instead of 'field-name-is-too-long-I-guess'. This causes SQL Server to error because that column does not exist in my DB table.

So has anybody seen this behavior, where the outfield name is truncated before the query makes it to the underlying database? Strangely, this doesn't happen in ArcGIS 10.2.1. I have the exact same setup with the same column names in a 10.2.1 environment and the outfield field name truncation does not occur. Does anyone know if there is a setting or configuration on my 10.4.1 ArcGIS Server or map service that controls field name size limits for queries?

P.S.

I get the same truncation behavior when I try to execute the query directly from the map service REST endpoint page as well. For some reason, 10.4.1 ArcGIS is not liking my field names that are longer than 22 characters...at least when it comes to querying on them...???

Any help would be greatly appreciated

0 Kudos
2 Replies
ThomasSolow
Occasional Contributor III

Sounds like an interesting issue.

I assume it's not a JS API bug if you can get this to work by changing the server version and leaving the JS API version the same.  I'd suggest filing an issue with tech support for server.

Of course the simplest solution might be to shorten the field name, if that's an option.

0 Kudos
KenBuja
MVP Esteemed Contributor