Repeat Loops or Repeat Dialogs

(Last updated June 2020)

A Repeat Dialog (aka a Repeat Loop) is a series of questions that will continue to loop based on criteria that the author sets. If the same type of information needs to be collected several times, such as children’s names or assets, a repeat dialog can be written to collect the series instead of using multiple questions, thus greatly increasing the efficiency in interview drafting.

 

There are two different approaches to creating a Repeat Dialog. While the approaches themselves are different, the results are the same: the end-user is asked the same questions more than once, as many times as they require. The two approaches are:

  1. Ask the end-user up front for the number of times a series should be repeated; and,
  2. Ask the end-user at the end of the series if they would like to repeat the series.

 

Ask the End-User Up Front for the Repeat Number

 

This approach is useful when the end-user will know up front how many times the questions will need to be repeated. An example of this is asking the end-user how many children they have, and then looping through and collecting the name of each child. There are seven steps to this approach.

 

  1. Create the counting variable under the Variables Tab.

    • The Counting Variable will “count” how many times the end user has gone through the set of questions in the loop.

    • The counting variable MUST be a number. (See figure below)

    • Counting variables should follow the naming convention of capitalizing all of the words in the name and leaving no spaces. They also should not include the two letter variable type indicator generally associated with variables. For example, ChildCount or AssetCount in Figure 124 are counting variables. They are easily distinguishable from other variable types.

 

Figure: Counting variables [ChildCount] and [AssetCount] in Variables Tab.

 

  1. Create the set of question that will be repeated.

    • This can include as many questions as needed.

      1. For example, the A2J Guided Interview could have a question collecting the child’s name, one for their date of birth, and one for their address.

  2. Create a “how many” question. This is the first question in the repeat loop, but it is not one of the repeated questions. It will only be asked to the end user once.

    • This question should ask something like “How many children do you have?” (Figure below)

    • The user’s answer should be captured in a number variable to be used later.

      1. Ex. [Number of children NU]

 

How many children.png

Figure: The “How Many” question.

 

  1. On the “how many” question, go to the buttons section of the question design window. Scroll down to the Repeat Options field and select “Set counting variable to 1” from the drop down menu. (figure below)

    1. Also identify the counting variable being used in this loop in the counting variable field under the repeat options field.

 

set counting variable.png

Figure: Setting the counting variable to 1 in the Question Design Editor.

 

  1. Identify the counting variable in the “Counting Variable” field on the question text section of the Question Design Editor of every question to be repeated. (figure below)

    1. Do not identify the counting variable on the question text section of the “How Many” question because that question should not be repeated. On the “How Many” question, only put the counting variable in the Buttons section.

    2. On the questions to be repeated, the Buttons Repeat Option should be set to “Normal.”

 

Show counting variable.png

Figure: Counting variable identified on a repeating question in the question text section of the Question Design Editor.

 

  1. On the last question to be repeated, go to the Buttons Repeat Option and set the field to “Increment Counting Variable” and identify the counting variable (figure below).

    1. When the user presses the “Continue” button on this question, the counting variable number will increase by 1.

Increment counter.png

Figure: Increment Counting Variable on the Repeat Option of the Question Design Editor.

 

  1. On the last question to be repeated, create a condition in the Advanced Logic section of the Question Design Window. This condition will compare the number held by the counting variable to the number the end user selected in the “How Many” question. The figure below gives an example of this advanced logic.

    1. The condition asks whether the number held by the counting variable is equal to the number given by the end user.

    2. If true, (the end user has gone through the loop the number of times they said they needed to go through it), the end user is moved out of the loop and into the next non-repeated question.

    3. If false, (i.e. the end user has not gone through the loop as many times as they said they needed to go through the loop), the end user is sent back to the first question of the repeating set of questions.

 

Logic for repeat.png

Figure: Advanced Logic for Repeat Loops.

 

Ask the End-User at the End if They Would Like to Repeat

 

The second way to create a repeat loop is to ask the end user at the end of the set of repeated questions whether they would like to add more. This approach is useful when the end-user may not know how many times the questions may need to be repeated. Below are screenshots that will demonstrate how to set up this type of Repeat Dialog. The steps are very similar to the first approach.

  1. Create the counting variable under the Variables Tab.

    1. The Counting Variable will “count” how many times the end user has gone through the set of questions in the loop.

    2. The counting variable MUST be a number. (Figure below)

    3. Counting variables should follow the naming convention of capitalizing all of the words in the name and leaving no spaces. They also should not include the two letter variable type indicator generally associated with variables. They are easily distinguishable from other variable type

AssetCount.png

Figure: AssetCount created on the Variables Tab.

 

  1. Create the set of question that will be repeated.

    1. This can include as many questions as needed.

      1. For example, there could be a question asking for the name of an asset over $100, one asking for the value of that asset, and one asking for the location of that asset.

  2. Create a question that leads into the loop of questions but is not repeated.

    1. This question should have 2 buttons, a “Yes” button and a “No” button. The question should ask the end user if they have any items that need to be covered by the looping questions. For example, “Do you have any assets over $100?”  (First figure below)

    2. On the “Yes” button, under the Repeat Options, “Set Counting Variable to 1” and indicate which counting variable is being used in the Counting Variable field (second figure below).

      1. When the end user selects “Yes” to the question “Do you have any?” they will be branched into the looping questions.

      2. The destination question should be set to the first of the repeated questions.  

    3. On the “No” button, the Repeat Option should be set to “Normal.”

      1. If the end user selects “No” they will not be taken into the looping questions and instead will be moved on to whatever question the author sets as the destination question.

 

Repeat Loops_Do you have any assets over $100.png

Figure: Example of the “Do you have any” question.

 

Repeat Loop Set Counting Variable to 1_AssetCount.png

Figure: Yes button Repeat Option designated to “Set Counting Variable to 1”

 

  1. Identify the counting variable in the “Counting Variable” field on the question text section of the Question Design Editor of every question to be repeated. (Figure below)

    1. Do not identify the counting variable on the question text section of the “Do you have any” question because that question should not be repeated. On the “Do you have any” question, only put the counting variable in the Buttons section.

    2. On the questions to be repeated, the Buttons Repeat Option should be set to “Normal.”

 

Repeat Loop_Asset Count in question text section.png

Figure: Counting variable [AssetCount] identified on a repeated question in the question text section of the Question Design Editor.

 

  1. The last question to be repeated should ask the end user if they would like to add any more (first figure below). On that question, in the Buttons section, set the “Yes” button to “Increment Counting Variable” in the Repeat Options field, set the “Destination” to go back to the first of the repeated questions, and indicate the counting variable being used (second figure below).

    1. By selecting yes, the end user has indicated that they need to go back through the repeated loop of questions.

    2. On the “No” button, the Repeat Option field should be set to “Normal” to move the end user out of the loop to the next non-repeated question (third figure below)

 

Repeat Loop_Asset Count_Any More_Preview Mode.png

Figure: “Do you have another” example question.

 

Repeat Loop_Asset Count_Any More question.png

Figure: “Yes” button options set for “Do you have another” question.

 

Repeat Loop_Asset Count_Any More_No option.png

Figure: “No” button options set for “Do you have another” question.

 

 

Repeat Loop Icon

 

    A2J Author visually indicates whether a specific question is part of a repeat loop by including an icon next to the question name on the Pages Tab and in the Map. The icon is a curved arrow (figure below). This icon is present whenever the author designates a counting variable in the question text section of the Question Design Window.

 

Repeat Loop_symbol shown in pages.png

Figure: Repeat Loop icon, the curved arrow, in the Pages Tab.

 

Variables in a Repeat Dialog

 

Variables in a repeated question are set up as normal except that you must check the "Repeat" box within the Variable Design Editor to indicate to A2J Author that the variable should be allowed to hold multiple values (figures below).

 

Repeat loop_variable within repeated question.png

Figure: Repeating variable in the Variables list.

 

Figure: Check if multiple values designates a variable that will be allowed to hold multiple values. 

 

The only difference on the question side is the question is identified as part of a repeat dialog by including a counting variable in the Counting Variable field in the question text section of the Question Design Window (figure below).

 

repeat loop_counting variable designated.png

Figure: Variable designated in the Counting Variable field.

 

Variables within a repeated question can hold multiple values. To hold multiple values, A2J Author creates an index of the values held by that variable. That index id represented visually by an appended pound sign or hashtag and the loop number to the end of the variable name, creating what look like new sub-variables each time the user goes through the loop.

 

For example, if a variable named, “Child name first TE” is used in a repeat dialog, and the end-user ultimately enters two (2) values (e.g., Betty and John), the following table shows how to access these variables in the text of a question. See Figure 140 for an example of this in the scripting panel of Preview Mode.

 

Variable

Value

Significance

%%[Child name first TE]%%

Betty and John

Shows all values gathered for 1 variable with commas and “and” separating them.

%%[Child name first TE#1]%%

Betty

Shows only the value held for the 1st round of the loop.

%%[Child name first TE#2]%%

John

Shows only the value held for the 2nd round of the loop

 

Repeat Loop_Multiple values_scripting panel.png

Figure: Multiple values held by the same repeated variable as seen in the debug panel.

 

The author can display the value held by just 1 round of the loop by using the variable macro %%[Variable name#CountingVariable]%%. An example of when this would be used is when the author has a set of repeated questions about the end user’s children. In the first question, the author asks for the child’s name. In subsequent questions, the author can use that child’s name to personalize the A2J Guided Interview. The first figure below shows a close up of this on the authoring end and the second figure below shows an example of it in use on the end user’s side.

 

Repeat Loop_Variable Macro_author end.png

Figure: Using a variable macro to call up the value of 1 instance of the repeated variable.

 

repeat loop_Variable Macro_Preview.png

Figure: An example of the macro used in the figure above in Preview Mode.

 

The author can also use the ORDINAL function in conjunction with counting variables. The variable macro formula is %%ORDINAL([CountingVariable])%%. This tells A2J Author to show the words “first,” “second,” “fifteenth,” etc. according to which round of the loop the current question is displaying to the end user. The first figure below shows the macro formula on the authoring side and the second figure below shows an example of it in Preview Mode.

 

repeat loop_ORDINAL_author side.png

Figure: ORDINAL used with a counting variable.

 

repeat loop_ORDINAL_Preview mode.png

Figure: ORDINAL used with a counting variable example in Preview Mode.

 

A training video for creating Repeat Dialogs in A2J Author is available at: https://www.youtube.com/watch?v=7fT5yDBnAt8