Different behaviour between Enketo and ODK Collect on trigger and instance

Thanks @Xiphware for your suggestions. Manually changing the the XForm is too complex for my currect level unfortunately :exploding_head: !

After some headaches and a long night, I found a solution suggested by @LN in this closely related thread: 'Trigger' a calculation at the 'end' of a form - #4 by LN

Enclosing the the calculation with once() triggers pulling the values from the external csv reliably also in Collect and allows changing the retrieved value or entering a new value when the field is not prepopulated from the csv.

The major disadvantage of this solution is that once the calculation has been carried out, it can no longer be changed by going back to a previous field and changing its value.

instance_test.xlsx (567.5 KB)

Another workaround is to insert a user filled question ("verify_code") serving as a trigger for the calculation (although this question does not make much sense otherwise). This will recalculate the field if the new question is reset. This solution is not perfect but a robust workaround.

To make this solution more reliable, it would be ideal if the trigger question ‘verify_code’ were set to empty each time it is opened to ensure that the calculation in the following field ‘producteur_nom’ is triggered again. I have not managed to achieve this yet. Does anybody have a suggestion?

instance_test_2.xlsx (567.9 KB)

Finally: The prefered solution would be if also Collect accepts trigger on calculated fields. @LN: would this be something that is considered in future versions?

1 Like