I think this is going to end up a multiple post issue as I try to work through labels / repeats / indexed-repeat values and rolling up summaries...
1. What is the issue? Please be detailed.
When a form results in a repeat with many findings, it is very helpful for the enumerator to see some more information in the Collect table of contents screen to be able to quickly find the one they need to return to. Seeing this is less helpful
Finding repeat > 1
Finding repeat > 2
Finding repeat > 3
Finding repeat > 4
Finding repeat > 5
Compared to something like this, or whatever combination of values is needed to quickly ID the finding (name / age / medication...)
Finding [corrosion] [severe] > 1
Finding [vibration] [moderate] > 2
Finding [corrosion] [light] > 3
Finding [coating] [minor] > 4
Finding [coating] [severe] > 5
So, initially, (naïvely!) I thought, no problem, just whack ${field-name} in the repeat label, job done.
Now, this works in Collect, but perhaps it shouldn't, as it doesn't work in Enketo and also doesn't work in Web Forms. However you can use ${field-name} in a label of a note/question inside a repeat in all three without having to refer to position within the repeat at all, so what makes the label of a repeat special compared to labels inside a repeat?
Then I thought, ok, we can use instance
expressions in labels, so I'll just try an indexed-repeat expression, but this both doesn't work, and gets really wonky in Enketo/WF as it started to show values from different choice lists in the broken expression somehow in another form.
I know the indexed-repeat logic is correct as I included a calculate inside the repeat with it and a note to display the result.
After that I tried to go back to an instance expression and then instance but include some position values, first with an indexed repeat and then with a selected-at (after joining the values outside the repeat to select on), all of these failed in different ways.
I'm currently out of ideas on how to further leverage xpath expressions for this (ping @LN!) , and am not sure if I've missed the solution, or if I should be able to use the field name directly and it's just that Enketo & WF aren't properly displaying the value (well Enketo can't as it only ever shows the repeat label once, but WF does repeat the label and doesn't even display it at all in the label, but does in the add repeat button ping @JenniferQ!)
While I could leave my form with only the direct field in the repeat label and be happy it works in Collect I'm concerned that a) this may not work forever, b) I could cause issues when editing / completing via web c) Web Forms cannot display a field in the repeat label at all currently and then suppresses text after the field
2. What steps can we take to reproduce this issue?
Try the attached basic form in Collect vs Enketo & WF
3. What have you tried to fix the issue?
- use the field code directly - Only ok for Collect. Enketo shows first value, but label not repeated. WF repeat label goes blank at expression and suppresses text after expression. 'add repeat dialogue' does evaluate expression and doesn't suppress, but only ever shows value for first repeat element
- use indexed-repeat directly - in a label it doesn't work properly anywhere but as a calculate then displayed with a field it does
- use an instance lookup directly - Only ok for Collect.
- use an instance lookup with indexed repeat as the filter - doesn't work properly anywhere
- use an instance lookup with selected-at as the filter (and a separate join outside the repeat) - doesn't work properly anywhere
- Asked kapa.ai varying versions of how to get a value for a certain element of a repeat
4. Upload any forms or screenshots you can share publicly below.
(to make it easier to keep adding new test cases for this form I created most of the field names and expressions as XL formulae, but this doesn't affect the outcome)
dynamic repeat labels.xlsx (586.8 KB)