Documate is now Gavel! Read more about why we’re excited about this rebrand.

Repeating Items - Other

There is so much you can do with Repeating Questions.  We've documented some of the other frequently requested options below:

Referring to the Prior or Next Item in a List of Repeating Items (see here)

If you want to create a loop where you continuously refer to the immediately preceding item in a list, here's how to do it using nextitem:

{{ nextitemlist(children, 'If it is not <childname>, then it is <next.childname>.') }}</next.childname></childname>

The example above would generate: If it is not Jane, then it is Jack.  If it is not Jack, then it is Jill.

Sorting Repeating Items (By Date or Otherwise)

Sometimes, the order in which repeating items are entered might not be the order in which you want them to be generated in the documents.  In that case, you can use the "sort" function.  The example below sorts a list of children by date using the variable "child_date_of_birth":

{% for item in children|sort(attribute=’child_date_of_birth’) %}{{ item.child_date_of_birth }}{% endfor %}

You can even sort two different repeating items (e.g., children and step-children) as long as they have the same underlying variable attributes, like this:

{% for item in (children+stepchildren)|sort(attribute=’child_date_of_birth’) %}{{ item.child_date_of_birth }}{% endfor %}

Unique Situation Using Repeating Items to Order Paragraphs

In some unique situations, you may have several paragraphs in your document that you want to appear in a different order each time, depending on the order in which they are chosen by the user.  For example, this is for the scenario where you might want Paragraph 1 to appear before Paragraph 3 in certain situations, followed by Para. 2.  

Here's how you can set this up using a Repeating Item question:

  1. Set up a Repeating Item question in your interview.
  2. Give it an Item Name (like "Clause" or "Paragraph")
  3. Set up one Multiple Choice question that asks about the Paragraph Choices. List all of the different clause choices.
  4. Use the syntax listed below in your Word or .docx document. Replace the choices with your clause names and replace the text with your actual text.

Here's how it looks in your interview and document:

alt text here

Here's what the syntax will look like in your document:

{% for item in Paragraph %}
{%p if item.ParaChoices == ‘Paragraph Choice 1’%}
1.    Choice 1 Text
{%p elif item.ParaChoices == ‘Paragraph Choice 2’ %}
2. Choice 2 Text
{%p elif item.ParaChoices == ‘Paragraph Choice 3’ %}
3.    Choice 3 Text
{%p endif %}
{% endfor %}

Show Only Certain Items in a Repeating Item

Let's say you want to enter Items 1-4 on one form, and items 5 and up on an overflow form/attachment. You can do the following to accomplish this:

{% for item in ItemName[4:50] %}{{ item.itemattribute }}
{% endfor %}