How to use the trigger column to clear repeat_count when a higher field has changed?

@nathalie_H and I are working on a sort of Holy Grail of forms :slight_smile: to monitor the conservation status of natural habitats.

Each habitat is evaluated, at the level of a parcel, according to three criteria which are its structure, its composition and its degradation.
For each of these criteria, we evaluate a list of indicators. These indicators are different from one habitat to another.
The structure of the form is :

  • loop into a parcel list of id (select_one)
    • select the habitat to be evaluated
      • loop into the list of "structure" indicators to fill the value
      • loop into the list of "composition" indicators to fill the value
      • loop into the list of "degradation" indicators to fill the value

We first tried to use dynamic repeat-count, and the ability to hide previously selected values in the pick list. This works fairly well but can be a source of discomfort or error when moving backward into the form.

So we looked for another way. Since we know how much indicators I have to fill for each criteria for each habitat, we use this value as repeat_count, and we added a "rank" column (from 1 to n) for each habitat and criteria, in order to filter it with choice_filter

habitat=${habitat_n2k} and rang = ${rang_stru}

At the end of the loop (using repeat_count) We jump to next criteria and so on.
It is less dynamic than the first scenario but probably more robust in term of backward navigation.

What we would like to do to complete this form is to reset all values relative to an habitat patch if the user goes backward and changes the habitat at the beginning of the form.

We tried to use triggers possibilities but we don't completely succeed. I wondering we just needed to ask collect to trigger when habitat changes but it is not sufficient for all the input.
It is OK to refresh the numbers of indicators for the new habitats and refresh the list, but we can't achieve to refresh/modify the repeat count. If the habitat we selected first need 3 indicators for the structure criteria, when we change to an habitat concerned by only 2 indicators, ODK will show a third "empty list" of indicators, as if the number of indicators was not refreshed by the trigger.

Here is a simplified version of the form (only the first criteria), without any trigger.

etats_conservation_hbt_n2k_forum.xls (31 KB)

thanks a lot for reading this long story :slight_smile:

1 Like

I changed the title and clarified some points :wink:

1 Like

I did not found a direct solution, but a sufficient workaround, using a test in the "relevant" column to show the the group containing the select_one and the integer value, only when the iteration number is inferior or equal to the number of indicators needed for the habitat.
In the end when I change from an habitat with 3 indicators to fill to another one with only 2, I get a blank third line in the submitted data.

the form : etats_conservation_hbt_n2k_forum_ok.xls (31.5 KB)
the data : etats_conservation_hbt_n2k_ok.csv.zip (1.5 KB)