Select to view content in your preferred language

Rule to restrict values to a subset of domain values in Survey123

1184
2
02-15-2020 06:13 PM
Status: Open
JohnMDye
Frequent Contributor

Instead of being required to make multiple fields to support different sets of values constraints in a dropdown, it would be nice to be able to just have all of those values populate into a single field and just constrain the eligible values. Essentially, I'm asking for subtype support.

Case in point:

Let's say I want to ask for the user for the address of a location and I want those values parsed. That's easy, let's set up a couple of questions to gather that information.

basic address capture form

Okay, but my locations could be in any country. To keep things simple, let's just say it could be in North America. Pretty straightforward, lets just add a Country question.

basic address capture form with country field

Oh! but my State question is a dropdown because I want the user to select a valid state and I'd like to avoid misspellings. Or perhaps I want to give them full state names but only keep the abbreviations in the table. Whatever my reason, it's a dropdown. Hmm...states from three different countries. That's going to be a long dropdown! We could use Autocomplete here to negate those length effects, but there's nothing stopping them from selecting the wrong value now is there? And with more choices, those odds also increase.

Okay. Let's address this. Survey123 Rules to the rescue! Let's set up a State dropdown for each country, containing only the state values for its respective country, then we'll set up a Rule on the Country dropdown to show the appropriate State dropdown based on the Country selection! Problem solved!

basic address capture form with country field and a state field for each country

Or is it? When you go to publish and modify the schema, you find that each of these individual State dropdowns now has its own respective field, with its own respective domain. Totally makes sense and that works for most use cases. But not this one. No one would want their state values spread across three different fields just because the state is located in a different country.

survey123 modify schema dialog with country states and domains spread across three fields

Doing that means that you've got a to implement a lot more logic whenever you're trying to feed an address into another system or perform a URL call. You're never sure which field to grab the state value from unless you implement additional logic in your app to identify the country. 

TLDR; Give me a rule that lets me have a single or multi-choice to which a rule can be attached, which allows me to constrain which values from another single or multichoice list that will appear in that item, based on the selected value in the question on which the rule was applied.

Something like:

If COUNTRY == 'United States' then in STATE only show values ['AL', 'AK', 'AR', ...]

If COUNTRY == 'Canada' then in STATE only show values ['AB', 'BC', 'MB', ...]

If COUNTRY == 'Mexico' then in STATE only show values ['AG', 'BC', 'BS', ...]

One State Field. Many possible values but which value(s) are eligible for selection depends on the country you selected.

2 Comments
JohnMDye

So I came across Contingent Values yesterday while researching this further. Not sure if they are supported in Survey123.