1. What is the problem? Be very detailed.
In the attached form, i want the enumerator to specify the relationship of each individual with the head of household i have the below options:
Self
Spouse
Son/Daughter
Sibling
Grandparent
Grandchild
Son/daughter in law
Mother/Mother in law
Father/Father in law
Other relative
Non-relative
I need to restrict and make it mandatory to select one individual as head of household (option 1)
Allow (option 5/grandparent) to be selected 4 times maximum 0 is allowed.
Allow options 8 and 9 to be selected 2 times maximum 0 is allowed.
2. What app or server are you using and on what device and operating system? Include version numbers.
Using ONA as a server and ODK collect v2021.2.4 for data collection
3. What you have you tried to fix the problem?
NA
4. What steps can we take to reproduce the problem?
I don't know
There are plenty ways for you to implement the desired restrictions. I added few rows in your form (self-explanatory). For some reasons, Enketo doesn't render well the choice_filters, consider testing the form in ODK for optimal results
Summary of work-around:
Use choice_filter() to limit available options based on repeat index
create counters of relationship occurrences (Grandpa, Mothers and Fathers) inside repeat
Outside repeat, sum() the occurrences
Inside the repeat, set constraint() or warning messages as notelabel or hint based on set thresholds and inform user on what to do via same note or constraint_message()
Hello @jules_rugwiro,
The shared code helped me get to the result needed. I just did a little twist as i needed the applicant data to be filled first regardless if this is the head of household or not.
I used the same logic used for the other household members.
Thanks for the support and happy new year:)
Chris