jhogan
October 24, 2025, 5:13pm
1
1. What is the issue?
Using the example of “XLSForm that looks up default values based on a selection” described Form Logic - ODK Docs , I added a second question (age) and I have no problem with the trigger/calculation populating the default when I wrap the questions in a field_list to get them on one page. However, if I place a repeat around it, then it appears that the trigger does not occur and the calculation does not populate the default. But if I remove the field_list while retaining the repeat, the trigger does seem to occur and the calculation populates the default.
I’m really confused because it works with field_list without a repeat and works with a repeat without a field_list.
2. What steps can we take to reproduce this issue?
Does not work:
selectlookuptest.xlsx (14.4 KB)
3. What have you tried to fix the issue?
Removing the field_list fixes this, but the desired behavior is to have both on same screen.
selectlookuptest-nofieldlist.xlsx (14.4 KB)
jhogan
October 25, 2025, 3:32am
4
The triggers are happening and I can get it to work in Enketo using the following for the calculation:
instance('participants')/root/item[name=indexed-repeat(${participant}, ${repeat_group}, position(../..))]/phone_number
However, when I try to use it on the device (Connect) it gives me an error:
Error Occurred
Index 1 out of bounds for length 0
selectlookuptest-enketoworking.xlsx (14.5 KB)
Could this be a bug in Connect?
edit: I added this to an existing open issue on github.. maybe it's related:
opened 01:17PM - 31 May 22 UTC
We've found a case where field lists do not update correctly when a question is … answered. I'll format this issue in a way that allows us to add any other cases we might find down the line (before making fixes) here as well.
### Trigger + Calculate + Relevant
#### Form
```xml
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa"
xmlns:odk="http://www.opendatakit.org/xforms" xmlns:orx="http://openrosa.org/xforms"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>Trigger relevant</h:title>
<model odk:xforms-version="1.0.0">
<instance>
<data id="trigger" version="1">
<field-list>
<a/>
<b/>
</field-list>
<meta>
<instanceID/>
</meta>
</data>
</instance>
<bind nodeset="/data/field-list/a" type="string"/>
<bind nodeset="/data/field-list/b" relevant="selected( /data/field-list/a , 'show')" type="string"/>
<bind jr:preload="uid" nodeset="/data/meta/instanceID" readonly="true()" type="string"/>
</model>
</h:head>
<h:body>
<group appearance="field-list" ref="/data/field-list">
<label>Field List</label>
<select1 ref="/data/field-list/a">
<label>A</label>
<item>
<label>Show B</label>
<value>show</value>
</item>
<item>
<label>Hide B</label>
<value>hide</value>
</item>
<setvalue event="xforms-value-changed" ref="/data/field-list/b" value=" /data/field-list/a "/>
</select1>
<select1 ref="/data/field-list/b">
<label>B</label>
<item>
<label>Show B</label>
<value>show</value>
</item>
<item>
<label>Hide B</label>
<value>hide</value>
</item>
<setvalue event="xforms-value-changed" ref="/data/field-list/a" value=" /data/field-list/b "/>
</select1>
</group>
</h:body>
</h:html>
```
#### Test
```kotlin
rule.startAtMainMenu()
.copyForm("trigger-relevant.xml")
.startBlankForm("Trigger relevant")
.assertQuestion("A")
.assertTextDoesNotExist("B")
.clickOnText("Show B")
.assertQuestion("A")
.assertQuestion("B")
.clickOnText("Hide B", 1) // Click the second "Hide B"
.assertQuestion("A")
.assertTextDoesNotExist("B")
```
## Notes
It would be good to take the opportunity to revise how widget values are saved as part of fixing this issue. We've chatted in the past about having widgets and `onActivityResult` call a modified `FormEntryViewModel#answerQuestion` that in turns calls `FormController#answerQuestion` (or similar) and then some kind of optimized reload (probably through an interface) instead of using `QuestionWidget#setData`, `WaitingForDataRegistry`, `WidgetValueChangedListener` etc.