Select to view content in your preferred language

Query parameters in search appearance expression

414
2
08-22-2024 12:12 PM
JillianStanford
Frequent Contributor

Can someone confirm for me that when searching a hosted feature layer to populate a select_one field appending query request parameters to the REST endpoint does not work in the web app? This limitation is not listed in the documentation but I get pretty funky behaviour.

For context, I have a drop down that I want to populate from a hosted feature layer. I need to filter the values based on a previous selection but I need to search multiple fields so I can't use the searchType, searchColumn and searchText parameters.

My solution is to query for the relevant records using the where query parameter. So, my appearance column looks like this -

w3 autocomplete search(concat("list_town?url=https://services2.arcgis.com/aIrBD8yn1TDTEXoz/ArcGIS/rest/services/Towns/FeatureServer/0/&where=CountyIntersect_1=",${county}," OR CountyIntersect_2=",${county}," OR CountyIntersect_3=",${county}," OR CountyIntersect_4=",${county}))

This works great in the Survey123 Connect app. When I look at the request in Fiddler all looks correct and the expected values show up in the drop down.

JillianStanford_3-1724353816764.png

However, when I publish the survey and open it in the web app, I get the following error:

JillianStanford_1-1724353684038.png

It's failing to load because it appears that the where parameter for the request makes no sense.

JillianStanford_2-1724353733873.png

Am I out of luck with this solution or do I need to configure the field differently?

Thanks!

Jill

0 Kudos
2 Replies
Sarah_Gates
New Contributor

Hi @JillianStanford - 

Try adding a calculate question before your select_one question, and moving the whole concat statement to the calculation field. So this -  concat("list_town?url=https://services2.arcgis.com/aIrBD8yn1TDTEXoz/ArcGIS/rest/services/Towns/FeatureServer/0/&where=Coun...",${county}," OR CountyIntersect_2=",${county}," OR CountyIntersect_3=",${county}," OR CountyIntersect_4=",${county})  - will be in a new calculate question.

Then, in your select_one question appearance, enter autocomplete search(${calculate_question_with_concat}) to reference the concat statement.

What version of S123 connect are you using? I've encountered what I think is a bug with the latest S123 update that affects search appearance questions in the 3.20 version of the web app. My workaround has been to publish the survey using a 3.19 version of Survey123 connect, and on the Survey123 website in Settings > Version select Use the version the survey was published with (3.19).

0 Kudos
JillianStanford
Frequent Contributor

Hi Sarah,

Thanks for the reply.

It looks like I am using Survey123 Connect version 3.19.104.

If I get a chance I will try your solution.

As a workaround, what I ended up doing is denormalizing the records into a hosted csv and searching that. It's not as dynamic as I would like and is one more piece of content to maintain but it allowed me to keep moving forward.

Thanks again!

Jill

0 Kudos