Is it possible to field-list on a repeat group?


#1

Hello,
I am trying to set up a repeat group in my survey. I would like all the questions within that repeat group to be displayed on the same screen.

I have tried this in a couple of ways:

  • “begin group”/“end group” with “field-list” in the appearance column and a number in the repeat_count column --> this succeeded in getting all the questions on the same screen, but the group did not repeat.
  • “begin repeat”/“end repeat” with “field-list” in the appearance column and a number in the repeat_count column --> this succeeded in repeating the questions, but the questions did not all appear on the same screen.

Do you have any guidance?
Thank you!


(Clayton Sims) #2

Hi Caroline,

You can create a repeat group inside of a field-list group (two groups instead of one) as long as the repeat has a set count by the time the user arrives at the question.

You cannot, unfortunately, use a repeat group which expands within the repeat group by user input (IE: “Add another repeat”)

-Clayton


#3

Thank you Clayton! it worked :slight_smile:


#4

Hello, I have one follow-up question: I am using several repeat groups in my survey. When an enumerator wants to go backwards to change a response in one of these repeat groups, CommCare crashes. Is that common or is there a problem with my code?

Best and thanks,
Caroline


(Clayton Sims) #5

Hi Caroline,

That’s quite odd. Does that change result in a difference in a future repeat group’s “count”?

Is CommCare giving you a useful error message about your form or XPath expressions? If so, it would be helpful to know what they are. If not, it would be helpful to Report an Issue through CommCareHQ outlining how to reproduce the issue so we can see where we are failing to catch and provide a useful error message for whatever the underlying issue is.

-Clayton


#6

Hello Clayton,

here is a screenshot of the error I get. I am also attaching a screenshot of the part of the code it is referring to: A_32a calculates the position of the repeat group. That’s what seems to crash when going backwards.

Let me know if you have any insights for me.

Best and thanks,
Caroline


(Clayton Sims) #7

Hi Caroline,

I’m not 100% sure what’s going on here specifically. One guess is that I noticed you have a Display Condition directly on the repeat group itself, which can sometimes cause problems with calculations like position(…), because the calculations trigger whether or not the display condition is met (causing issues if the repeat itself isn’t actually displayed).

Putting the display condition on a group inside of the repeat (and allowing the surrounding repeat to exist with no display condition) will address that, I believe.

-Clayton


(Cody Stahl) #8

Hi Caroline,

As Clayton mentioned, position() calls can cause apparently strange behavior within repeat groups when combined with display conditions.

I’ve found the most reliable workaround to be to update the calculate condition of any question that uses the position() function so that it’s wrapped in an if() block, of the format if([display conditions of any groups the question is in],[original calculate condition],["")

For example, with A_32b, which is where your error seems to be happening, you can convert the calculate condition into something like:

if(#form/A_31 > 0, position(..) + 1, "")

Hope this helps!
-Cody