Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entities form with a choice filter and a mismatch error suggesting to use indexed-repeat() #6421

Closed
dbemke opened this issue Sep 18, 2024 · 3 comments
Milestone

Comments

@dbemke
Copy link

dbemke commented Sep 18, 2024

ODK Collect version

the master version 66e9c1f

Android version

10, 14

Device used

Redmi 9T, Pixel 7a

Problem description

While creating forms with entities and choice filters I noticed a mismatch error suggesting to use indexed-repeat().

Steps to reproduce the problem

Example 1:
child updateCOnst.xlsx.txt
child_only_registration_without_age_limit.xlsx.txt

  1. Start with the dataset without children- no entities with property age < 18 (if necessary delete entities on Central).
    https://staging.getodk.cloud/#/projects/101/app-users

  2. Download the user "children” to Collect.

  3. Fill the child-only registration without age const form and enter age < 18 and send the form.

  4. Refresh the list of blank forms.

  5. Go to child update with const filter form.

  6. Select the created child, fill the form and save as draft.

  7. Go to "Drafts” and open the form.

  8. From the hierarchy view go to the first question (selected child is deselected).
    firstDraft

  9. Discard the changes and go back to the main menu.

  10. Go to "Start new form”, fill the child-only registration without age const form and enter age < 18 and send the form.

  11. Refresh the list of blank forms.

  12. Select the second created child, fill the form and save as draft.

  13. Go to "Drafts” and open the form (there’s a mismatch error).

  14. Go back to "Drafts” and open the first draft that was created (there’s a mismatch error).
    MismatchIndexedRepeat

Other information: The mismatch error also appears when the user opens a finalized form.

Example 2:
child update filter name.xml.txt
child update filter name.xlsx.txt

  1. Download the user "children” to Collect.
    https://staging.getodk.cloud/#/projects/101/app-users
  2. (if necessary) Fill the child-only registration without age const form and enter "Tom" in name field, send the form and refresh the list of blank forms.
  3. Fill child update filter name form and save it as draft.
  4. Go to "Drafts” and open the form (there's a mismatch error).
@lognaturel
Copy link
Member

Can you please do a quick check on v2042.2? This looks like an existing issue to me.

@dbemke
Copy link
Author

dbemke commented Oct 10, 2024

Can you please do a quick check on v2042.2?

I managed to reproduce the same error on v2024.2.4 with changed entity spec in forms from the issue.

@seadowg seadowg added this to the v2024.4 milestone Oct 10, 2024
@lognaturel
Copy link
Member

There's a calculation of instance('children')/root/item[age< 18] on the child select. I think the intent was to put age < 18 in the choice_filter column and that's it.

There are a couple of form design issues here:

  • Having a calculation on a user-modifiable field is generally not going to be a good idea because it will reset any value that the user selects. This is something we've considered warning about from pyxform but haven't done yet.
  • instance('children')/root/item[age< 18] can potentially give back multiple values if there are multiple children with an age less than 18. It's not possible to store multiple values in a single field.

That second issue is what the error ends up being about. It's basically saying 'child' is a field and you're trying to store multiple items here but you can't. You could do something like join(', ', instance('children')/root/item[age< 18]) but you can't just store the result of requesting all items with age less than 18 if there is more than one match. In this case, the indexed-repeat suggestion is nonsense, which relates to getodk/javarosa#700

@lognaturel lognaturel closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
@github-project-automation github-project-automation bot moved this from not ready to done in ODK Collect Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: done
Development

No branches or pull requests

3 participants