Select to view content in your preferred language

Calculation in nested repeat not triggering

83
0
Thursday
Neal_t_k
MVP Regular Contributor

I ran into what appears to be a Survey123 web form issue with nested repeats and wanted to share. I haven't seen this exact issues brought forward.  I think I have it solved for my purposes. I am posting to see if anyone else has ran into the issue, has any explanations or alternate solutions

My form structure is:

Main form ->Product repeat->Ingredient repeat

Inside the Ingredient repeat, I have a simple hidden calculated field based on another question in the same repeat ( if (selected(${<field}, 'A'), 'A', 'B')>. The calculation worked correctly in Survey123 Connect and the Field App, but in the web form it behaved inconsistently.

  • All Ingredient records under the first Product calculated correctly.
  • In subsequent Product repeats, the calculated Ingredient record would not recalculate and stayed at the default value.
  • Calculation mode appeared not to have an affect.

Adding a relevant clause to the calculated question seemed to solve some of the issue (string-length(${<field>})>0) as it delays the trigger until there is an answer to the previous question. However, after adding the relevant clause the first record of each subsequent repeat still displayed this issue unless I added a second ingredient and then returned to the first ingredient of the second product, it would then recalculate correctly.

Changing the calculationMode from 'auto' to 'always' appears to have fixed this form my situation. But I believe it has to do with the re-evaluate calculations upon submit, more than fixing the behavior as it replicates the go back to question one trigger, not actually solving the why it didn't trigger on the first ingredient of the 2nd product issue.

Again thought I would share and see if anyone else has thoughts.

 

0 Kudos
0 Replies