Jr:choice-name() not re-evaluated on form language change

1. What is the issue? Please be detailed.
When changing the form language, jr:choice-name() does not appeared to be re-evaluated.

Swiping backwards and forwards is enough to update calculations that are triggered by a variable, but calculations without implicit or explicit triggers are never updated.

When expressions are evaluated suggests a number of points when expression will be evaluated, but we've noticed when passing static values into jr:choice-name() sometimes a calculation could go through multiple form submissions without being re-evaluated.

2. What steps can we take to reproduce this issue?
Calculate a variable with jr:choice-name() and then change the language.

3. What have you tried to fix the issue?
We've tried adding a trigger value based on the last user-selected choice in the form. This mostly works, but still requires a user-initiated change (which doesn't work, for example, if the calculated value needs to be displayed on the first page in the form).

4. Upload any test forms or screenshots below.
ODK - jr_choice-name() test v2.xlsx (14.7 KB)

UPDATE: I added a v2 of the test form and screen recording that more clearly shows the two failure situations, specifically:

  1. Notice how after changing the language, neither of the calculated values have been translated.
  2. Notice after swiping backwards and forwards, the calculated value with an implicit trigger on ${veggie} is updated, but the one based on 'carrot' is not.

Just to note, this might not be entirely correct... I think it could also be explained by jr:choice-name() running with the default form language, before the last user-selected language is applied, when starting a new form.

Hi @TobiasMcNulty

Thanks for reporting the issue. It is weird indeed. I've tried wrapping that note along with the calculations into a group to force recalculating but to no avail. @LN what do you think about this issue?

Sorry about the radio silence. This is annoying, indeed. Your best bet in the short term is doing what you've figured out and including the choice name lookup in a bigger expression that will force recomputation.

The engine tries to be smart about when it recomputes dynamic labels because it can be expensive to go through all of them for long forms. Currently language change does not trigger recomputation. It likely should at some point but that's probably not a simple addition.

You may also be interested in some of what I described at Accessing translations to use within XLSForm - #2 by LN.

1 Like