web app: "failed to load the choice list" generated by search()

2518
5
Jump to solution
07-26-2023 12:53 PM
mikaël
Frequent Contributor

In my XLSForm, I have this choice list that is generated from a search() function, which querys a table in the AGOL feature service. I set it up based on the doc and this blog post.

The list loads fine when working in Survey123 Connect and on the android app. However, that is not the case in the survey123 web app where I get a "Failed to load the choice list. Please contact the survey owner to fix it." error. There is an empty box with an arrow but clicking on it brings nothing (except the field name as a popup).

Survey123 Connect (peoples names so hidden):

mikAMD_0-1690400407132.png

Web app:

mikAMD_1-1690400454901.png

In my XLSForm, under the choices tab, I have:

list_namenamelabel
ins_pnprenom_nomprenom_nom

 

and in my survey tab (the field name in question is binded to null because I then get the ID of the user (inspecteur_man_id) and that's what I want to store):

typenamelabelappearancerequiredcalculationbind::esri:fieldType
select_one ins_pnprenom_nominspecteurminimal search("prenom_nom?url=feature_service_url/FeatureServer/10/query?where=1=1&orderByFields=inspecteur_man_id asc")yes null
integerinspecteur_man_idinspecteur_man_idhidden pulldata("@layer", "getValue", "attributes.inspecteur_man_id", "feature_service_url/FeatureServer/10", concat("prenom_nom ='", ${prenom_nom}, "'"))esriFieldTypeInteger

 

Am I doing something wrong? From what I understand, search() is supposed to work in the web app.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
mikaël
Frequent Contributor

All right!

 
So I again found the problem! It seems it was not related at all with the "minimal" or "autocomplete" appearance.
 
As stated here, I added query parameters to the url i put in the search() function:
 
Tip: You can optionally append query request parameters to the REST endpoint of your feature layer or map service layers to configure the search behaviour. This can be really useful for incorporating buffers of query geometry using &distance= and &units=, as well as limiting the number of query results using &resultRecordCount=. These URL parameters can also be set by the user in the form itself, see the Point intersects buffered points (with attribute filter) example below for details.
 
So I had put in the "appearance" field this: 
      autocomplete search("entree_inspecteur_man?url=feature_service_url/FeatureServer/14/query?where=1=1&returnDistinctValues=true&outFields=entree_inspecteur_man")
 
This was causing the "failed to load choice list" in the web app, although it was working in Survey123 Connect and the Android app.
 
While troubleshooting, I finally removed everything from query, so the "appearance" now looks like this: 
      autocomplete search("nom_unique?url=feature_service_url/FeatureServer/14")
 
Works like a charm!
 
Thanks!

View solution in original post

5 Replies
mikaël
Frequent Contributor

So it seems the problem is with the "minimal" appearance. Changed it to "autocomplete" and everything works fine. Although "minimal" should be supported as stated in the doc!

0 Kudos
mikaël
Frequent Contributor

Apparently I was a little bit hasty.

Everything was working fine, I changed the appearance to "minimal" just to check something in Survey123 Connect. Then changed it back to "autocomplete", and doesn't work once again in the web app. Still getting the "Failed to load the choice list" error.

0 Kudos
mikaël
Frequent Contributor

All right!

 
So I again found the problem! It seems it was not related at all with the "minimal" or "autocomplete" appearance.
 
As stated here, I added query parameters to the url i put in the search() function:
 
Tip: You can optionally append query request parameters to the REST endpoint of your feature layer or map service layers to configure the search behaviour. This can be really useful for incorporating buffers of query geometry using &distance= and &units=, as well as limiting the number of query results using &resultRecordCount=. These URL parameters can also be set by the user in the form itself, see the Point intersects buffered points (with attribute filter) example below for details.
 
So I had put in the "appearance" field this: 
      autocomplete search("entree_inspecteur_man?url=feature_service_url/FeatureServer/14/query?where=1=1&returnDistinctValues=true&outFields=entree_inspecteur_man")
 
This was causing the "failed to load choice list" in the web app, although it was working in Survey123 Connect and the Android app.
 
While troubleshooting, I finally removed everything from query, so the "appearance" now looks like this: 
      autocomplete search("nom_unique?url=feature_service_url/FeatureServer/14")
 
Works like a charm!
 
Thanks!
SWT_TL
by
Emerging Contributor

I am also getting this issue.

Or more precisely, I'm not getting this issue but other users of the survey are.

The solution identified here is not working for me, and even so it would be ideal to keep the added parameters to filter down the choice list by answer to a previous question.

Has anyone identified any further solutions?

0 Kudos
jonoian
New Contributor

Hi @mikaël and @SWT_TL. I've encountered the same issue though I fixed it by encoding the characters within the URL. For reference, my Survey123 Connect question uses the additional parameters of units, distance, and where using a LIKE sql statement. Below is an example of how it looked within the search statement when it was not working on the Surevy123 web app:

autocomplete search("list_sites?url=someRestUrl&units=esriSRUnit_Meter&distance=0&where=siteCode LIKE 'TEST2025%'", "intersects", "@geoshape", ${activityPolygon})

While the above statement worked as expected on Survey123 Connect and within the Survey123 Mobile App, it would crash and display 'Unable to load choice list. Please contact the survey owner to fix it.' when accessed from the browser. To fix this url, I had to encode special characters such as the whitespaces, the % sign, and the single quotation marks so that they are read appropriately. This resulted in the search statement appearing as so:

autocomplete search("list_sites?url=someRestUrl&units=esriSRUnit_Meter&distance=0&where=siteCode%20LIKE%20%27TEST2025%25%27", "intersects", "@geoshape", ${activityPolygon})

This version of the URL appears to work for me in both the mobile app and the web app. Here, the whitespaces have been replaced by %20, the single quotation marks have been replaced by %27, and the % sign has been replaced by %25. I think this webpage is a good reference for url encoding parameters (https://www.w3schools.com/tags/ref_urlencode.ASP).

 @mikaël for your purpose, try copying the URL as it is displayed on ArcGIS Online (see circled in blue in below image). Then use this reference for configuring the URL parameters to add to the end of it (https://developers.arcgis.com/rest/services-reference/enterprise/query-feature-service-layer/#exampl...).

Hope this helps!

 

jonoian_0-1740443163045.png