Select to view content in your preferred language

Pick list from a field in a feature service?

523
17
Jump to solution
4 weeks ago
AmyRoust
Frequent Contributor

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:

AmyRoust_0-1755272801416.png

 

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:

AmyRoust_1-1755272938766.png

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:

AmyRoust_2-1755273088307.png

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?

 

 

2 Solutions

Accepted Solutions
ChristopherCounsell
MVP Frequent Contributor

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:

  • list_name = building_name_list
    • This is just a name for your list in the survey. Make it obvious it's the list.
  • name = 'buildingname'
    • This should be the actual field name in your service you are trying to search for to create your choice list. 
  • label = 'buildingname'

In your survey form:

  • type = select_one building_name_list
  • name = buildingname
    • I'm assuming you're searching this field / the same service
  • label = What building has the issue?

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:

https://community.esri.com/t5/arcgis-survey123-blog/dynamic-choice-lists-using-search-appearance/ba-...

 

 

View solution in original post

AmyRoust
Frequent Contributor

Mystery solved. This only works with a hosted feature service, and I was using a user-managed service from my Portal.

View solution in original post

0 Kudos
17 Replies
HannesVogel
Frequent Contributor

did you try "autocomplete search(....)"?

0 Kudos
AmyRoust
Frequent Contributor

Yes. When I add autocomplete, I get a blank drop-down box.

0 Kudos
ChristopherCounsell
MVP Frequent Contributor

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:

  • list_name = building_name_list
    • This is just a name for your list in the survey. Make it obvious it's the list.
  • name = 'buildingname'
    • This should be the actual field name in your service you are trying to search for to create your choice list. 
  • label = 'buildingname'

In your survey form:

  • type = select_one building_name_list
  • name = buildingname
    • I'm assuming you're searching this field / the same service
  • label = What building has the issue?

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:

https://community.esri.com/t5/arcgis-survey123-blog/dynamic-choice-lists-using-search-appearance/ba-...

 

 

AmyRoust
Frequent Contributor

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?

0 Kudos
HannesVogel
Frequent Contributor

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:

HannesVogel_0-1755799234782.png


the formula in the appearance field in xlsform looks like this:

HannesVogel_1-1755799457165.png

 

0 Kudos
AmyRoust
Frequent Contributor

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.

0 Kudos
ChristopherCounsell
MVP Frequent Contributor
The field name is the name in your choices sheet. I used it in the example.
0 Kudos
AmyRoust
Frequent Contributor

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.

0 Kudos
HannesVogel
Frequent Contributor

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 '

 

0 Kudos