Save questions form the repeat group to the case properties

(ferdinand) #1

Hi folks,

I have a repeat group that registers contacts of a patient in a registration form but Iam unable to save questions in this repeat group as case properties. Iam able to save as case properties only the questions that are not in the repeat group. I need help on this issue.

Thanks in advance


(Mazen AlAli) #2


This is not really an “issue” or unexpected behavior.

Cases are singular items. or, if you want to look at them that way, they are a database row. and as i’m sure you are aware, you can only store one value per row for each column (property)

So, if you have a repeat group and you’re collecting an answer to a question inside it such as “what’s your favorite color?” you’re going to get a color, multiple times. as many times as the group question is repeated. so, if you were to select that question and tried to store the answer as a case property, there’s no way for the system to know which property you’re after. or if it’s the average of all the answers, a long string of all the answers, or whatever other operation it needs to do to come up with one singular value that it can store as a case property.

you have 2 options:

1- use a join or similar function to concatenate all those answers into one long string, or use an average function, but do that outside the repeat group after the group is finished. this way, you’ll have a hidden value with all the answers to that question in the repeat group, and you can store that against this case. you will need to read the following links before you can accomplish this
Logic outside repeat groups:
Commcare string functions

2- you want to store all the answers to that question in the repeat group separate from each other. for this, you will need to create child cases. these can be of the same type as the case you’re trying to update, or they could be different cases. for more information on that, please look at this link
This will allow you to create a new child case with the current case as its parent, for an many times as that repeat group repeated. you can also use attributes from the parent case and copy them across to the child cases too.

1 Like

Repeat group issue
(ferdinand) #3

Thank you,Mazz, for your clear explanation. I will read the links you have shared.