Select to view content in your preferred language

Editing after a change to select_one choice list

207
2
08-30-2024 01:56 PM
JeffShaw
Frequent Contributor

How do you handle situations where your choices for a select_one question are dynamic (i.e. they change over time) and you need to edit a previous submission?

According to Esri, "The use of dynamic (constantly changing) choice lists in Survey123 has become a popular feature…"

For example, values are removed from the choice list, but previous submissions need to retain their existing value when editing a submission, even if that choice is no longer in the list.

I have a select_one question that gets its choices from a feature table using search with a URL in the appearance setting, as described in the link above. But when you open a previous submission to edit it, the existing value for that question gets cleared out if the value is no longer in the choice list. 

Adding calculationMode=whenEmpty to bind::esri::parameters doesn't help. And adding the select_one question separately and making it visible or relevant only when the original value is blank results in a dependency error.

2 Replies
DavidSolari
Frequent Contributor

Add a new column to your "choices" after "label" and name it "enabled" or some other name you like. For every choice set the column to 1 if it's enabled or 0 if it isn't. Then go back to the "survey" tab, go to the "choice_filter" column and set it to "enabled=1". Now the only choices in the form are those that you've enabled, but the entire list is intact for compatibility.

This might cause issues with editing forms if older data is edited through the inbox instead of another ArcGIS app. One thing you can try is adding a hidden field with the default set to a version number, then every time you adjust the list you bump the version number and make the "enabled" value that version. Then you can do "(enabled = 3 and ${version} = 3) or (enabled = 2 and ${version} = 2)" etc. This isn't something I've tried personally but it should be a step in the right direction.

0 Kudos
JeffShaw
Frequent Contributor

Those are great ideas David and I hadn't tried using the choice_filter column. Unfortunately I couldn't get it to work the way I hoped.

The value is being preserved if you resubmit, but I had wanted to display the existing value in the pulldown, rather than nothing as shown below.

JeffShaw2_0-1725070782125.png

I am pulling the choices from a feature table rather than a CSV or the choices tab, and I can't get the choice_filter column expression to work at all -- when added it always returns an empty list. I did try applying the filter as a parameter with the search URL, and it does filter the choice list, but it doesn't solve the display problem either. The choice_filter column expression does work when getting the choices from the Choices tab, but I still get the empty pulldown if the value isn't in the filtered list, even if the value is in the unfiltered list.

I could make a read-only text box visible when there is an existing value, and make a select_one visible when it's null, but the question is in a repeat and I need the user to be able to add new entries. Using the calculate expression to do so is when I run into the dependency loops.

0 Kudos