cascading select multiple

1772
5
12-08-2020 10:44 AM
LauraEDugan
New Contributor II

I just updated to version 3.11 and am trying to implement a cascading select_multiple using choice_filters, which was added with this update (https://doc.arcgis.com/en/survey123/faq/whatsnewsurvey123.htm). However, I am having some problems. I have three levels of select_multiple questions. As an example, if options 8 and 9 are selected in question 1, two more questions appear with options 8.1, 8.2, 8.3, etc. and 9.1, 9.2, 9.3, etc. Then, if 8.2, 9.1, and 9.2 were selected in these questions, more questions would appear with options 8.2.1, 8.2.2, etc.; 9.1.1, 9.1.2, etc.; and 9.2.1, 9.2.2, etc. (see image).

Example of level I, II, and III questionsExample of level I, II, and III questions

In practice, going from level I to level II questions works. If I select three level one options, three more questions appear offering level II values related to each level I option selected. Then, if I only select ONE level II option in a question, the level III options appear (see above), but if I select two or more, the question labels appear, but not the options.

Two level II options selected causes an errorTwo level II options selected causes an error

Here is the syntax for the questions in the form:

typenamelabelrelevantchoice_filter
select_multiple threat_categorythreat_cat_genGeneral Threats:${threats}='Y' (there is a previous question called ${threats} asking if there are known threats to the species) 
select_multiple threat_invasivethreat_invasiveSpecific Invasive & Other Problematic Species, Genes, & Disease Threatsselected(${threat_cat_gen},'32') 
select_multiple threat_invasive2threat_invasive81Specific Invasive Non-native/Alien Species/Diseases threats(selected(${threat_cat_gen},'32') and selected(${threat_invasive},'33'))filter=${threat_invasive}
select_multiple threat_invasive2threat_invasive82Specific Problematic Native Species/Diseases threats(selected(${threat_cat_gen},'32') and selected(${threat_invasive},'34'))filter=${threat_invasive}
select_multiple threat_invasive2threat_invasive83Specific Problematic Species/Diseases of Unknown Origin threats(selected(${threat_cat_gen},'32') and selected(${threat_invasive},'142'))filter=${threat_invasive}
select_multiple threat_invasive2threat_invasive84Specific Viral/Prion-induced Diseases threats(selected(${threat_cat_gen},'32') and selected(${threat_invasive},'145'))filter=${threat_invasive}

 

Note that I also tried regex(filter, concat('.*', ${threat_invasive},'.*')) as the choice_filter (for those questions with one) and had the same issue.

Here are the choices in the choices sheet for level I threats:

Level I choicesLevel I choices

Here are the choices in the choices sheet for level II threats:

Level II choicesLevel II choices

Here are the choices in the choices sheet for level III threats:

Level III choicesLevel III choices

I think it has to do with that when more than one level II options are selected, more than one number is stored in the second-level threat question (e.g., in ${threat_invasive}) and this is conflicting with the choice filter, but I don't know how to fix it. Here is the form validation when the level I threats selected are pollution and invasive species, and one level II option is selected for pollution and two are selected for invasives meaning the level III options are visible for pollution, but not for invasives:

"threats": "Y",
"threat_cat_gen": [
"32",
"36"
],
"threat_agri_aqua": null,
"threat_pollution": [
"39"
],
"threat_pollution91": null,
"threat_pollution92": null,
"threat_pollution93": null,
"threat_pollution95": null,
"threat_pollution96": null,
"threat_invasive": [
"33",
"34"
],
"threat_invasive82": null,
"threat_invasive81": null,
"threat_invasive83": null,
"threat_invasive84": null,
"destination_repeat": []
}

(Side question: why does threat_agri_aqua even appear here when it wasn't selected and the others that weren't selected are not listed?)

Is what I'm trying to do even possible? Or, do I need to make individual choice lists for every level II option (I hope not...there are a lot).

Thanks!

0 Kudos
5 Replies
Jim-Moore
Esri Regular Contributor

Hi @LauraEDugan 

I think your theory is on the right track - the choice filter expression filter=${threat_invasive} is expecting one value, but the threat_invasive question is a select_multiple, so you'll likely need to use a different technique here. The Cascading Selects sample in Survey123 Connect has several examples on how to set up choice filters for select_multiple questions, including the use of regular expressions. Perhaps a regular expression like regex(${threat_invasive},filter) might work?

Not sure about the  threat_agri_aqua question - if possible, could you please attach your XLSForm?

Best,

Jim

0 Kudos
LauraEDugan
New Contributor II

Hi @Jim-Moore . Thank you for your response. I had tried one regex formula, and it didn't work. However, I tried this one, and it does, except that it shows all level III choices for each level II choice selected for each level III question that becomes relevant (see screenshot below).

All level III choices shown for each questionAll level III choices shown for each questionGetting much closer.

I am attaching my xls form here. Thanks again for your help.

0 Kudos
Jim-Moore
Esri Regular Contributor

Hi @LauraEDugan 

Thanks for attaching your XLSForm.

As you're seeing, if more than one choice is selected for the level II select_multiple, the regex() will return multiple matches. For example, if threat_invasive has answers 8.1 and 8.4, the value stored for this question is '33,142', so all choices matching 33 and 142 will be returned. You want to return the '33' choices only for one question, and the '142' choices only for another question, so I think in this case the solution is to use separate choice lists for each level III option. Because each choice list is discrete (i.e. the level III choices are unique/static for each level II choice) and displayed in its own question, there is no need to use a choice filter. You've already implemented relevant conditions to control which questions (and choices) the user sees.

If you wanted to have only one question for level III and dynamically adjust the choices presented in it from a longer list if all potential level III choices, a choice filter would be necessary.

I also noticed that the select_multiple questions have bind::esri:fieldType set to integer, which is incompatible with select_multiple questions as the answer to a select_multiple is stored as a comma-separated string (for example, '33,142'). Select_multiple questions use a string field in the feature layer by default. Note that if you want to save each selected response as an integer, you could consider using the technique described in this blog post to save out the selections to separate fields. See the Controlling how user selections are stored in ArcGIS section.

Regarding the threat_agri_aqua question appearing in the form validation, is it possible that this choice was selected and then deselected? In that case the remnant entry might still be shown in the field list. In any case, the value is null so no data would be sent for this field on submit.

Best,

Jim

0 Kudos
Jim-Moore
Esri Regular Contributor

Hi again @LauraEDugan - forgot to mention that this blog post is another excellent resource:

https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-choice-filters/ba-...

 

0 Kudos
LauraEDugan
New Contributor II

Hi @Jim-Moore . Thanks also for this. It is a great resource. I have spent some time on this page, but still couldn't figure out my specific issue.

0 Kudos