PROBLEM

Unable to access fields with periods in field names through a service in ArcGIS API for JavaScript

Last Published: April 25, 2020

Description

When accessing the property of a feature class that contains a period in the field name (for example, SHAPE.AREA), the script reads the property as a separate part and labels the property as undefined.

Cause

The period in JavaScript dictates an access of an attribute or the calling of a method or function of an object. For example, map.setExtent calls for the object map, and uses the function setExtent.

If a line of code refers to a field name in a feature contains periods, for example:

result.features[0].attribute.SHAPE.AREA
This results in the JavaScript failing to define the property after SHAPE, and returns the result as undefined for the property.
 

Solution or Workaround

To counter the script from reading the name as a separate part, the attribute value must be accessed by passing the field alias on an array. For example:
results.features[0].attributes["SHAPE.AREA"]
Note:
In the original code snippet, calling a field alias is done using the exact alias of the field. In the counter code, the code uses an array that searches any attribute field with the name SHAPE.AREA. This method can be modified to vary the range of search. To increase the accuracy of the search parameter and to get only the desired fields, use the full alias name.

Article ID: 000014782

Software:
  • ArcGIS API for JavaScript 4 x
  • ArcGIS API for JavaScript 3 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options