In a dynamic repeating section, you don't have to specify the number of times the section must be repeated beforehand (as is the case with regular repeating sections). Instead, at the end of each repeat, you can indicate whether you want the section to repeat again or not.


Using dynamic repeating sections could be useful in a scenario such as this:


A fieldworker needs to capture information on each street in a particular neighbourhood. All the information about each street should be captured in the same form. To get all the information that they need to capture, the fieldworker needs to go to each household on the street and ask the same set of questions. The number of households in each street differs and the fieldworker does not know beforehand how many households there are in each street.


To set up a dynamic repeating section, you will need to follow the 4 steps below. To illustrate, we are using the example mentioned above.

  1. Add a numeric variable with a default value of 1. This variable will be evaluated to determine whether your repeating section should be repeated again. Since this field will not display when conducting the form, you can add this variable to the first section of your form. Note: your first field cannot be a variable, so ensure that there is at least one other field before this one.







        This is what it will look like in the form design view:




2.  If you haven't already, add a section containing all the repeating fields you need to capture. Set the section's repeating properties to use the variable in Step 1 to determine how many times it must repeat.  




3. Add the following fields to the repeating section in Step 2:

  • A multiple choice field type ('Select One'). In our example, the fieldworker needs to confirm whether they would like to capture information for another household:




        The options for this field need to be 'Yes' (with a value of 1) and 'No' (with a value of 0):




  • A set operator. This operator will set the variable you've added in Step 1. The value of this variable will be summed with that of the answer at your multiple-choice field. 



        

        In our example, we have used the field IDs to identify the relevant field in the operator. The operator             that you need to use can be set up as follows: 

            

            __{SET(Variable ID),__{ROUND(__{SUM(Multiplechoicefield ID,Variable ID)}__,0)}__)}__. 




  • A reprocess operator. This operator will check the value of the variable that you set up at Step 1. 




        Your operator should look like this: __{REPROCESS(Variableid)}__. Again, we used the variable's field ID,         but you can choose to use the field name if you prefer. 





4. Lastly, you need to add a prerequisite to your reprocess operator (added in Step 2). The reprocess operator should be skipped if the variable at Step 1 does not equal __{INDEX}__. This is to prevent problems with the operator should the fieldworker press 'Back'.



This is what it will look like in the form design view:




This is what your complete dynamic repeating section will look like in the form designer: