Repeat Loops or Repeat Dialogs

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 required. 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.

    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 124)

    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. For example, ChildCount or AssetCount in Figure 124 are counting variables. They are easily distinguishable from other variable types.

 

Childcount.png

Figure 124: Counting variable [ChildCount] in Variables Tab.

 

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

    1. This can include as many questions as needed.

      1. For example, the 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.

    1. This question should ask something like “How many children do you have?” (Figure 125)

    2. 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 125: 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 126)

    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 126: Setting the counting variable to 1 in the Question Design Window.

 

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

    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 127: Counting variable identified on a repeating question in the question text section of the Question Design Window.

 

  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 128).

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

Increment counter.png

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

 

  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. Figure 129 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 129: 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 130)

    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 130: 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?”  (Figure 131)

    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 (Figure 132).

      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 131: Example of the “Do you have any” question.

 

Repeat Loop Set Counting Variable to 1_AssetCount.png

Figure 132: 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 Window of every question to be repeated. (Figure 133)

    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 133: Counting variable [AssetCount] identified on a repeated question in the question text section of the Question Design Window.

 

  1. The last question to be repeated should ask the end user if they would like to add any more (Figure 134). 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 (Figure 135).

    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 (Figure 136)

 

Repeat Loop_Asset Count_Any More_Preview Mode.png

Figure 134: “Do you have another” example question.

 

Repeat Loop_Asset Count_Any More question.png

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

 

Repeat Loop_Asset Count_Any More_No option.png

Figure 136: “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 137). 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 137: 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 (Figure 138).

 

Repeat loop_variable within repeated question.png

Figure 138: Variables within a repeated question.

 

The only difference 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 139).

 

repeat loop_counting variable designated.png

Figure 139: Variable designated in the Counting Variable field.

 

Variables within a repeated question can hold multiple values. To hold multiple values, A2J Author appends a pound sign or hashtag and the loop number to the end of the variable name, creating 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 140: Multiple values held by the same repeated variable as seen in the scripting 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. Figure 141 shows a close up of this on the authoring end and Figure 151 shows an example of it in use on the end user’s side.

 

Repeat Loop_Variable Macro_author end.png

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

 

repeat loop_Variable Macro_Preview.png

Figure 142: An example of the macro used in Figure 150 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. Figure 143 shows the macro formula on the authoring side and Figure 144 shows an example of it in Preview Mode.

 

repeat loop_ORDINAL_author side.png

Figure 143: ORDINAL used with a counting variable.

 

repeat loop_ORDINAL_Preview mode.png

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

 

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