English

How To: Query another feature layer to return attributes based on the location of a geopoint question

Summary

When creating a survey form, it is possible to return attributes based on the location of a geopoint question intersecting with a different feature layer in ArcGIS Survey123 Connect, using the JavaScript sample. This article describes the workflow to query a different feature layer for attributes based on the location of a geopoint question in ArcGIS Survey123 Connect.

Procedure

  1. Log in to ArcGIS Survey123 Connect.
  2. Create a new survey, and select the Samples option.
  3. In the search bar, search for JavaScript.
  4. Select the JavaScript sample, and click Create survey.
Selecting the JavaScript sample in ArcGIS Survey123 Connect.
  1. Click XLSForm and modify the questions. Delete the unnecessary examples except for the Working with a Feature Service example.
  2. In the hidden field type for adminURL, replace the URL in the default column to the preferred layer.
Note:
Make sure the URL is redirecting to the layer within the feature service.
  1. Modify the functions in the calculation columns for the rest of the fields accordingly for the queries to return the desired results. Refer to ArcGIS Survey123 Blog: Extending Survey123 smart forms with custom JS functions for more information.

    The image below shows the example of the featureByLocation function is used in adminFeature, and the fieldValueByLocation function is used in adminName.

Note:
The featureByLocation function is used to return the JSON object of the polygon feature with which the point from the geopoint question intersects. The JSON object may then be further processed to extract specific attributes. The fieldValueByLocation function is used to return a specific attribute from the field. Refer to ArcGIS Survey123: Known limitations for more information.
The example of the featureByLocation and fieldValueByLocation functions used in the calculation columns for query purposes.
  1. Save the changes, and publish the survey form.

The image below shows the example of the query results.

The example of the query results being returned based on the on the location of a geopoint question.

Related Information

Last Published: 6/10/2021

Article ID: 000025459

Software: ArcGIS Survey123 3.9, 3.8, 3.7, 3.6, 3.5, 3.4, 3.3, 3.2, 3.12, 3.11, 3.10, 3.1, 3.0, 2.9.Classic, 2.8 ArcGIS Online 9.1