Query an ArcGIS Server feature service for select_one values

313
3
03-10-2021 10:25 AM
ColeMcLaughlin
New Contributor

Hello, I have been trying to find a way to have the pulldata function, or something similar, retrieve values from a feature service on our ArcGIS Server that has been loaded into AGOL.  I have seen a few different articles that seem to talk about this but none mentioning the exact situation I am in.  Here is my scenario:

We have a survey123 form built in Connect off of a Feature Service we have in our ArcGIS Server, the survey is recording hospital patient admissions/updates/discharges.  We would like to be able to query this feature service in an autopopulate select one question.

The workflow is as follows;

  • User fills out an admission record and enters a Medical Record Number (MRN) for a patient in a text question and then submits the survey and data is sent to the database table.
  • User then at a later time fills out an update or discharge record, this triggers a new select one question not previously available in the admission record, this select one question is able to pull data from the feature service table with a list of MRN values previously entered.

Any assistance would be greatly appreciated.  Thanks!

0 Kudos
3 Replies
DougBrowning
MVP Notable Contributor

This feature is still in beta.  Need at least 3.12 to test

Here is the help from early adopter.  Images do not paste so I suggest joining here

https://earlyadopter.esri.com/project/article/item.html?cap=e69ef91f45744b98882c651f7b518eb7&arttype...

Dynamically loading choices from feature services

The search() appearance allows you to query ArcGIS feature services and populate choice lists based on the results of the search query. When using the search() appearance with ArcGIS services you can use @geopoint, @geotrace, and @geoshape for the searchColumns depending on the geometry of the feature service you are querying.

For search type the following searchTypes are supported, this list comes from the spatial relationship parameter when querying a feature service or layer:

        Intersects
        Contains
        Crosses
        Envelope_intersects
        Index_intersects
        Overlaps
        Touches
        Within
        Disjoint
When using a feature service, the tableName parameter will be “<tablename>?url=<Layer REST URL>” and the REST URL will include the layer index for the specific layer you want to query. In the example below we are querying the Wildfire Perimeters feature service so the tableName URL that gets specified is wildfire?url=https://services3.arcgis.com/T4QMspbfLg3qTGWY/ArcGIS/rest/services/Public_Wildfire_Perimeters_View/F.... We will provide a few samples that use the Wildfire Perimeters feature service below but will focus on searching for fires based on state for the remainder of the documentation.

As outlined below, feature services can also perform attribute queries and are not limited to spatial queries as outlined above. The syntax is very similar to the method used for CSV files with the exception of the tableName pointing to a feature service instead of a CSV file. 

Similar to the CSV implementation, specify the selection question you would like (select_one or select_multiple) and specify a choice list name. You will then enter your search expression. 

 

 


In the sample above we specify our feature service URL as the tableName; for the searchType “startswith” is being used; the searchColumn is the UNITID field from the feature service; and the State abbreviation is being passed along from the previous selection question.  

On the choices sheet the list_name is specified to match the selection question. The name is specified as the field from the feature service we want to store in the survey’s service, and the label is the field from the feature service we want to be displayed in the choice list.

 

 


You will then be able to filter choices from an external feature service based on a spatial selection.

 

 


Here is a video that may also help with getting started: https://www.youtube.com/watch?v=eEXa8GK4yE4

hope that helps

0 Kudos
ColeMcLaughlin
New Contributor

Thank you very much Doug,

I saw that Search() function mentioned in the teaser for the new 3.12 version of Survey123.  It sounds like just what I need, can you confirm that it would work for attribute queries from a non-spatial table?  Looking forward to having this implemented.  Thanks again.

0 Kudos
DougBrowning
MVP Notable Contributor

I do not see why it would not.  I have only used it for CSVs though since we are always offline.

You can try it out in 3.12 which is now on the play strore.

0 Kudos