Infinite loop and dynamically delete already selected options from list

Godd evening to all, hope everybody is ok.

I face a problem I can't resolve.
We drive a field servey of plants species inventory. Species list are different from on site to another (I use choice filter to manage it).
For the moment I builded my form in a non generic, hard to modify way : -> A select widget for the abundance of each species :scream:

Reading yesterday some great recipes on the forum, I tried and I achieved to merge two great ones from @LN and @jules_rugwiro :


So my colleagues can now loop in the species list until the select 'no more species' AND the previously select species get out of the list, so the can not count the same species two times.
This works really fine.

Now I want to include it into a bigger repeat group (lines 13 & 29 in the attached xls file)
indefinite_repeat_and_remove_already_selected_from_species_list.xlsx (10.8 KB)
This repeat group concern the locations visited on the field.

But when I try it I get a error from xlsformonline:

Error: ODK Validate Errors:

Something broke the parser. See above for a hint.
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
The following files failed validation:
Result: Invalid

I do not have any idea about the reason but I am not an xlsform guru :frowning:

I haven’t had a chance to look at your form yet but I’m guessing that you are trying to do this in a nested repeat, is that right? If so, you are running into a Collect bug that we hope to publish a fix for this week.

Yes exactly :grinning: A first repeat of geopoint and inside an infinite repeat for species.
Great to ear that it will probably work !
Now I remember I red something about this bug... but I am not sure... This will be a very useful form for us.

1 Like

May be I was too optimistic in my last message because I get the error when I try to transform the xls file into xml, not in colect...

Yes, that makes sense. The error is in JavaRosa which both use. We'll aim to publish a pyxform/XLSForm Online fix soon as well.

1 Like

Quick update here. We ended up doing a Collect point release without this fix because I noticed some problems with it and was pulled into other time-sensitive work. I hope to get back to it by the end of the week.

1 Like

Collect v1.26.3 is now out and should fix this issue.

However, I have since realized that the sample form can cause an infinite loop in Collect when using the hierarchy view or finalizing. To avoid this, you can change the count expression to add a check for blank values: ${count} = 0 or (${taxons_observes}[position()=${count}]/espece != '' and ${taxons_observes}[position()=${count}]/espece != 'maille_suivante'). I have updated the original sample form accordingly. Please give it a try and let us know how it works for you, @mathieubossaert!

1 Like

For the moment I still can't transform the xls to xml with XLSForm Online.

Ah, indeed, I had converted the form some weeks ago and forgot you'd run into that!

indefinite_repeat_and_remove_already_selected_from_species_list.xml (10.1 KB) is the XML I got by making the change described above and running the converter without the Validate step. I'll try to get XLSForm Online updated sooner than later.


Thanks @LN it works perfectly !

I spoke too fast.
The form logic is ok but I realized that the form has not been saved (Collect is still finalizing / saving the instance).

I have to kill Collect (1.26.3) and when I restart it, I am unable to load the form while the scrren freeze on "Loading"

:sob::sob::sob: Do you remember when I said that there was a change needed to the form design to make sure there wasn't an infinite loop on finalization? I sent you the converted form without making that change. So sorry about that.

Hopefully this one works better: indefinite_repeat_and_remove_already_selected_from_species_list.xml (10.2 KB)

1 Like

Works great. Thanks @LN :grinning:

I am facing a problem with this form. I am preparing the 2022 field season and I would like to use this generic form, as the number of species and sites is now too big to use a none generic way.
On the collect side, the form is well finalized at the end of data collection (as I said in the last message).
I try it today and go forward with submissions. And I realize that species code (select_one especes) is empty.

I can't understand why so I think it could be a bug ?

Here are the form and submission data archive
suivi_maille_generique.xlsx (14.1 KB) (1.5 KB)

It is quite weird, when I add a calculate field containing ${espece} this calculation is ok and this field is well submitted to Central, but select_one still empty.

suivi_maille_generique.xlsx (14.1 KB)

Thanks to @LN I managed to get it work :

Here is the final form !
suivi_maille_generique.xlsx (14,2 Ko)
Edit : because I forgot to "unhide" the geopint question :wink:

1 Like