Unable to evaluate 'position' on... error

I have a repeat group that collects the information on the ‘branches’ a shop keeper has. The number of times the repeat group loops is controlled by the answer to the question “How many branches does this VBA (= shop keeper) have”.

This works well if you go through the questions without going backwards. However, if you enter a value greater than zero for the number of branches and go into the repeat group and then immediately go back to change the number of branches (because you made a mistake), when you delete the number you entered you immediately

get the error: Unable to evaluate ‘position’ on… See attached screenshot.

Your help with this would be appreciated.

Regards

Simon
20/12/17

Hi Simon,

Can you please share the display condition on /data/branches/next_branch_label, as well as information about any other Hidden Value questions that it might reference? I’m having trouble replicating this error.

Here you go:

I’ve just realised the error occurs even before you enter the repeat group if you delete the value of branches_num

FYI the other display conditions are:

Simon

Hi Simon,

Thanks for asking and apologies for the delay. Things got busy around the Holidays. Unfortunately, this may be a known limitation of repeat groups. Below, I’m about to paste an explanation and link to an article with more details:

Note on an important limitation of Repeat Groups: It is currently not possible for CommCare to delete a node within a repeat group once it has been created. This is important for implementation best practices in the following way: For questions where the repeat count is controlled by a user-input question, if the user enters an initial value and then changes it to something smaller (so from 2 to 1 for example), 2 repeat nodes will still show up. In order to prevent this inconsistency, you can do the following:

-Add a group question type immediately within your repeat group, and place all of the inner contents of the repeat group inside that inner group.

-Put this display condition on the inner group: position(…) < /data/repeat_count (where data/repeat_count is the integer question that defines the repeat count)

While it is unusual that an error is thrown in this circumstance, we cannot advise deleting and reentering the amount of times your repeat group should iterate. Can you please verify whether you still see that error after implementing the above? More info can be found in this Confluence article.