I'm struggling to interpret Esri's instructions for generating a pick list from a feature service for a select_one question in Survey123 Connect. I'm referencing the Search function.
Here's what I'm getting from the documentation:
In the choices tab, enter the list name (doesn't matter what I call it), the name (must be the field name in the feature service that I want to pull values from), and the label field (doesn't matter what I call it). Here's my config:
Then, in the survey tab, I populate the type as select_one buildingname (with the part after the select_one statement matching the list_name value in the choices tab), the name (with the name of the field in the feature service), the label (does not matter what I put here). Here's my config:
Then, in the same tab, same row, I have to populate the appearance column with the search() function and the correct parameters, which are supposed to be search(tableName, searchType, searchColumn, searchText, filterColumn, filterText). I can tell that tableName is the URL of the service (including the number of the sublayer), but after that, I get hazy. Here's what I have so far:
That syntax does not actually generate a drop-down menu on the survey. If I add the autocomplete parameter, I get a blank drop-down.
Help?
Solved! Go to Solution.
You don't need to (and probably shouldn't) use the same key term 'buildingname' for everything. You're tripping yourself up.
change your choice list:
In your survey form:
Now the expected formula for search() is:
search(tableName, searchType, searchColumn, searchText, filterColumn, filterText)
For your tablename, you need a URL preceded by a unique table name that doesn't match anything else in your Survey123 form. So call this literally anything but any other table or csv name in your survey. I don't think technically you have a table/csv name in your survey that may cause issues, but it's just not unique, it's confusing. Call it 'cats' or 'notarealtablename'.
The tableName with the URL is your only required parameter. The below will work. If it doesn't, check you have access to the service:
search(cats?url=https://services.arcgis.com/......./0)
You have added a search type for 'contains', a spatial search, and then a column 'buildingnames'. This would be expected for text based searches, where 'contains' expects a geometry. I assume you are trying to pull the buildingnames fieldnames for your choice list - this is what the name/label columns in the choices sheet are for. The search() parameters are for text based filtering. If you need to filter the results let us know and we can help build it. If you don't need to filter, query or apply a spatial search - just use the above search(tablename) without any additional parameters.
Also, the Survey123 blogs are a much better resource than the documentation:
Mystery solved. This only works with a hosted feature service, and I was using a user-managed service from my Portal.
did you try "autocomplete search(....)"?
Yes. When I add autocomplete, I get a blank drop-down box.
You don't need to (and probably shouldn't) use the same key term 'buildingname' for everything. You're tripping yourself up.
change your choice list:
In your survey form:
Now the expected formula for search() is:
search(tableName, searchType, searchColumn, searchText, filterColumn, filterText)
For your tablename, you need a URL preceded by a unique table name that doesn't match anything else in your Survey123 form. So call this literally anything but any other table or csv name in your survey. I don't think technically you have a table/csv name in your survey that may cause issues, but it's just not unique, it's confusing. Call it 'cats' or 'notarealtablename'.
The tableName with the URL is your only required parameter. The below will work. If it doesn't, check you have access to the service:
search(cats?url=https://services.arcgis.com/......./0)
You have added a search type for 'contains', a spatial search, and then a column 'buildingnames'. This would be expected for text based searches, where 'contains' expects a geometry. I assume you are trying to pull the buildingnames fieldnames for your choice list - this is what the name/label columns in the choices sheet are for. The search() parameters are for text based filtering. If you need to filter the results let us know and we can help build it. If you don't need to filter, query or apply a spatial search - just use the above search(tablename) without any additional parameters.
Also, the Survey123 blogs are a much better resource than the documentation:
Thanks, Christopher! This was a really helpful post that clarified a lot of my confusion. Do you know if the sharing settings on the service or the service type makes a difference? I'm trying to use a user-managed feature layer that is pulling data from a registered enterprise database. The layer is shared to a group, and the user that I'm using for the form is a member of that group. I don't get any error messages when I save, but the list is still empty.
One thing I wonder: how will Survey123 know which field to pull data from if I am only referencing the layer in the service?
Hi Amy, I use the search from a featureservice with referencing the field in the choices tab in the xlsform. i.e. I search in the GWM layer from the featureservice in the field "Bezeichnung" like this:
the formula in the appearance field in xlsform looks like this:
Oh yes, that's right. I forgot it was in the Choices tab. I double-checked my entry to make sure that I had the field name right, and it matches my service. Still no choices showing in the drop-down menu on the survey form.
OK, then I've got that formatted correctly. I guess I'll just have to put in a help desk ticket because everything matches and I'm still not getting any results.
another difference I noticed is you used the sign ' at the beginning and end and I used ". You also used 'contains' - maybe change that to contains without '