Survey123 Tricks of the Trade: Open lists

1849
7
11-01-2023 05:15 PM
IsmaelChivite
Esri Notable Contributor
11 7 1,849

 

 

Open Lists? Please explain

 

Most lists in your Survey123 forms are 'closed'. That is a term I just made up, by the way. Closed lists are those where the choices have been predefined: The author of the survey creates a list, and respondents pick choices from it.  There is nothing wrong with closed lists. Here is one example:

YesNo_List.gif

Sometimes, you need more flexibility and let people enter choices not present in the list. Adding a choice called 'Other' is the typical solution to that problem. When the 'Other' choice is selected, a free text question is shown so the respondent can enter a value not present in the list, as shown below:

Team_List.gif

In the example above, despite adding the 'Other' option, we are still working with a closed list.  Any extra values manually typed will be recorded, but not added to the list. Whatever value is typed under the 'Other' category, is saved in a separate field and the main list remains untouched (closed list).

Open lists are different: They automatically grow as respondents add extra values.    Can't find a value you want in the list? Select Other, type it in the free text question and submit. The next time the survey is opened, the new value will show up in the list! 

2023-11-01 Open List.gif

 

Working with open lists. Step by step

 

To include an open list in a survey, you need to create a list that feeds from a feature layer. As records are added to the layer, more choices show in the list.

It is a bit tricky to configure a survey to do this, but it is possible. Here are step by step instructions.

Start by building a survey like shown below. Ultimately, we want to create an open list for the Species question, but for now, we want it as text.

IsmaelChivite_6-1655744958778.png

Here is what the XLSForm looks like:

IsmaelChivite_0-1698868649773.png

After publishing the survey, Ask small group of people to collect a few records. Here is an example of what I got. Note that some of the species introduced are repeated. That is expected.

IsmaelChivite_1-1698874955243.png

Now that you have your survey layer populated with some species records, you can use the species field as the source of choices for a list.  Add a new select_one question and make it feed from the species field.  This is done by using the search appearance.

IsmaelChivite_1-1698868921355.png

If you are not familiar with the search appearance for select_one questions, check out this help topic and this blog by @BrettStokes 

Over the next steps, our goal will be to have a list and a free text question where people can enter extra values. We will also take the input from either the list or the extra text question to populate the species field.

Add now a new text question to store extra values. In the form below, I called the question species_other. Set the relevant expression so this question is only shown when the value Other is selected in the list.  Set the bind::esri:fieldType column to null for both the list and free text questions as shown below:

IsmaelChivite_0-1698872559504.png

In the species question, you are going to enter a calculation to auto-populate the value using either the extra value entered in the species_other question, or the selected value from the species_list list. This is accomplished through the coalesce function. For example, coalesce(${species_other},${species_list}) will return the value entered in the species_other question and, if this value is empty, will return the value selected in the list.  This calculation does the trick, as it will populate the species field, which ultimately is the source of all values presented in the list.

IsmaelChivite_2-1698874368944.png

Publish and try your survey now.  What you will find is that the list is missing a choice called Other. This makes sense, because you have not entered yet any record with that value. 

Thankfully, you can go into the survey layer and update one of the records with the value Other as shown in the animation below.

2023-11-01 Adding Other.gif

 

The next time you open the form, your list will show a choice in the list for Other. At that point the Other question will appear. After entering an extra value in the Other question, the species field will be populated accordingly.  I am sure you now understand how this works!

Naturally, you will not want to show the species text question to end users. In the XLSForm, change its question type from text to calculate (or hidden).

IsmaelChivite_3-1698874412399.png

Publish again, and you are set!

Limitations and some additional tips

 

Tip: Lists in Survey123 present choices sorted alphabetically. This will make the Other choice appear somewhere in between other choices, which is not ideal. I like to see Other either at the very beginning, or at the very end of the list.

  • To display 'Other' at the top of the list, add a tilde at the beginning: ~Other
  • To display 'Other' at the bottom of the list, prefix with the Greek Xi: ΞOther

If you add the tilde or Xi, to your data, you will also want to adjust the relevant expression accordingly. For example:

IsmaelChivite_0-1698874827838.png

For cosmetic reasons, I added Xi as a prefix and a suffix. You choose what you like better.

Limitation: Everything I described here will work well as long as your survey is connected. If you are working in offline mode, the list will not be populated because Survey123 will not be able to query the survey layer.

 

 

 

7 Comments