Complex Cascading selects with Filtering multiple-choice option lists

1. What is the problem? Be very detailed.


I did not find the syntax to combine severals filters to create a variable list,

is it possible to apply severals filters in a same time, for example

instance('ChoiceObs')/root/item[selected(current()/../../q1 , filter)]
or (+ condition)
instance('ChoiceObs')/root/item[filter = 1]

a more complex question,
in the example form below,
if the two choices of the Q1 selection are armed


is it possible to find in the second select
this three item because the value of "filter" contains the value of a response of Q1

<item><filter>FLAV</filter><label>Add observation Flavescence case 1</label><value>Flavescence1</value></item>
<item><filter>FLAV XYL</filter><label>Add observation Flavescence case 2</label><value>Flavescence2</value></item>
<item><filter>XYL</filter><label>Add observation Xylella</label><value>Xylella</value></item>

"Selected" work if "filter" is strictly the same as a value of an item Q1
"Contains" work, but if we arm two choice in Q1, the value is a string of the concatanation of both, so contains can't be use

This in order to share a large list without having to repeat it for each case.

<instance id="ChoiceObs">
			<label>Add observation Xylella</label>
			<label>Add observation Flavescence case 1</label>
			<filter>FLAV XYL</filter>
			<label>Add observation Flavescence case 2</label>
			<label>Nothing to observe</label>

<select1 ref="/data/repeat_parcelle/repeat_observation/q2">
 <label>Add an observation ?</label>
   <!-- <itemset nodeset="instance('ChoiceObs')/root/item[selected(current()/../../q1 , filter)]"> -->
   <!-- <itemset nodeset="instance('ChoiceObs')/root/item[filter = /data/repeat_parcelle/q1]"> -->
   <itemset nodeset="instance('ChoiceObs')/root/item[contains(/data/repeat_parcelle/q1, filter)]">
	<value ref="value"/>
	<label ref="label"/>

the example form :

04testForm.xml (2.9 KB)

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

I directly create my forms in xml in my notepad.

If you have examples of forms xls or xml that deal with complex cases of Cascading selects with Filtering multiple-choice option lists, I would love to read them to learn the syntax used.


Finally I found the solution to my first problem,
with the keyword search "choice-filter" in the forum I found this example

Thanks mathieubossaert and LN for this example form in their post.

It was a problem of syntax, solved in the example by

<itemset nodeset="instance('ChoiceObs')/root/item[( (filter= 1 ) or ( selected(current()/../../q1 , filter) ))]">
<itemset nodeset="instance('ChoiceObs')/root/item[(filter= 1  or  selected(current()/../../q1 , filter) )]">

Now like i can combine severals filters, I have resolved my second question, however it is not viable for a Q1 with more than two choises.

<itemset nodeset="instance('ChoiceObs')/root/item[( (filter= 1 ) or ( contains(/data/repeat_parcelle/q1, filter) )  or  ( contains(filter, /data/repeat_parcelle/q1) ) )]">

04testForm.xml (3.1 KB)

This was not the right approach i will do it differently, but i learned something.

I resolved it by adding more options on a item to be able to filtering each case,

	<label>Add observation Xylella</label>
	<label>Add observation Flavescence</label>

and applied filters

<itemset nodeset="instance('ChoiceObs')/root/item[( (contains(current()/../../q1, filterXYL)) or (contains(current()/../../q1, filterFLAV)) or (contains(current()/../../q1, filterSHA))  )]">

04testForm.xml (3.6 KB)


1 Like