Repeating Items within Repeating Items (BETA)

With Repeating Items within Repeating Items (beta feature), you can ask the same question multiple times to collect data about each entry in a larger repeating item.  For example, you may use a repeating item to collect information about a client’s children and a repeating item within that repeating item to collect information about a client’s grandchildren.

To add a repeating item within a repeating item to your workflow, first add a repeating item question. Repeating Items/Questions must be on a separate page from other questions.  Please create a new page in your interview to add one.

Then, add at least one question to your repeating item.

Click add another, and in the question type dropdown, choose “Repeating Item.” Give the repeating item within a repeating item a name, and add at least one question.

As with a standard repeating item, you can choose to ask an initial question if there may not always be entries in this repeating item within a repeating item for each entry in the main repeating item. In this example, we are choosing to ask an initial question because one or more of the client’s children may not have children of their own.

We can also choose to collect entries in the repeating item within a repeating item on the same page or on separate pages using the “Collect items on a single page” box.

Since repeating items within repeating items will always be shown on their own page, you can also designate a page title. By default, the page title will be ${ordinal(i)} and the name of your main repeating item. This will display the ordinal number of the corresponding entry in the repeating item for which the repeating item within a repeating item is being shown.

We can replace this page title with any standard page title, such as “Grandchildren.” We can also use syntax to display a value from the corresponding entry in the main repeating item.

To do this, we can use the syntax ${ItemName[i].AttributeName}. You will replace ItemName with the item name of your main repeating item, and you will replace AttributeName with the name of the attribute from the main repeating item that you would like to display.

In the example below, we are displaying our client’s child’s name when we ask if that child has any children.

Repeating items within repeating items will always be on their own page when the workflow is run, so for the best user experience, we recommend unchecking the “Collect items on a single page” box when using repeating items within repeating items.

The end-user experience with the configuration above is shown here.

Repeating Items within Repeating Items in Word Documents

Here’s how to format your Word documents to include the data from a repeating item within a repeating item:

{% for item in ItemName %}

{% for nesteditem in item.NestedItemName%}

{{ nesteditem.NestedAttributeName }}

{% endfor %}{% endfor %}

Here

  • ItemName is the name you gave the main repeating item.
  • NestedItemName is the name you gave the repeating item within a repeating item.
  • ItemAttributeName is the variable name for that repeating item within a repeating item's attribute.
  • All other syntax should remain the same.

 

Example:

Here’s an example for collecting information about the client’s children and grandchildren:

{% for item in children %}

{% for nesteditem in item.grandchildren %}

Name: {{ nesteditem.FirstName }}

Birthdate: {{ nesteditem.dob }}

{% endfor %}{% endfor %}

Here, children is the main repeating item’s name, and grandchildren is the repeating item within a repeating item’s name. FirstName and dob are the attributes of grandchildren that you want to display.

Note that you can also include information from the main repeating item as shown here:

{% for item in children %}

My child {{item.ChildName}} has the following children:

{% for nesteditem in item.grandchildren %}

Name: {{ nesteditem.FirstName }}

Birthdate: {{ nesteditem.dob }}

{% endfor %}{% endfor %}

All of the above syntax can be inserted in your Word document using the Repeating Item section of the no-code Word add-in.

Repeating Items within Repeating Items in PDFs

To include data from a repeating item within a repeating item in a PDF output document, load the unlocked document to the Output Documents section of your workflow and choose "Enter Text" for the PDF field.

Then, enter the following:

${ItemName[#].NestedItemName[##].AttributeName if len(ItemName)># and len(ItemName[#].NestedItemName>## else ""}

Here:

  • ItemName is the name you gave the main repeating item.
  • # is the number of the entry in the main repeating item you want to access, starting from zero. (For the first entry, # will be 0, for the second entry, # will be 1, etc.) All instances of # in a field should be the same.
  • NestedItemName is the name you gave the repeating item within a repeating item.
  • ## is the number of the entry in the repeating item within the repeating item that you want to access, starting from zero. (For the first entry, # will be 0, for the second entry, # will be 1, etc.) All instances of ## in a field should be the same.
  • ItemAttributeName is the variable name for the repeating item within a repeating item's attribute.
  • All other syntax should remain the same.

Example:

Here’s an example for displaying the name of the first child's third child:

${children[0].grandchildren[2].grandchildname if len(children)>0 and len(children[0].grandchildren>2 else ""}

Here, children is the main repeating item’s name, and grandchildren is the repeating item within a repeating item’s name. grandchildname is the attribute of grandchildren that you want to display. Since you want to display first entry in children's third entry in grandchildren, # is replaced with 0 and ## is replaced with 2.