(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:
- Ask the end-user up front for the number of times a series should be repeated; and,
- 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.
-
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.
-
Create the set of question that will be repeated.
-
This can include as many questions as needed.
-
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.
-
-
-
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.
-
Ex. [Number of children NU]
-
-
Figure: The “How Many” question.
-
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)
-
Also identify the counting variable being used in this loop in the counting variable field under the repeat options field.
-
Figure: Setting the counting variable to 1 in the Question Design Editor.
-
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)
-
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.
-
On the questions to be repeated, the Buttons Repeat Option should be set to “Normal.”
-
Figure: Counting variable identified on a repeating question in the question text section of the Question Design Editor.
-
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).
-
When the user presses the “Continue” button on this question, the counting variable number will increase by 1.
-
Figure: Increment Counting Variable on the Repeat Option of the Question Design Editor.
-
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.
-
The condition asks whether the number held by the counting variable is equal to the number given by the end user.
-
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.
-
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.
-
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.
-
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. (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. They are easily distinguishable from other variable type
-
Figure: AssetCount created on the Variables Tab.
-
Create the set of question that will be repeated.
-
This can include as many questions as needed.
-
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.
-
-
-
Create a question that leads into the loop of questions but is not repeated.
-
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)
-
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).
-
When the end user selects “Yes” to the question “Do you have any?” they will be branched into the looping questions.
-
The destination question should be set to the first of the repeated questions.
-
-
On the “No” button, the Repeat Option should be set to “Normal.”
-
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.
-
-
Figure: Example of the “Do you have any” question.
Figure: Yes button Repeat Option designated to “Set Counting Variable to 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)
-
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.
-
On the questions to be repeated, the Buttons Repeat Option should be set to “Normal.”
-
Figure: Counting variable [AssetCount] identified on a repeated question in the question text section of the Question Design Editor.
-
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).
-
By selecting yes, the end user has indicated that they need to go back through the repeated loop of questions.
-
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)
-
Figure: “Do you have another” example question.
Figure: “Yes” button options set for “Do you have another” question.
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.
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).
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).
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 |
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.
Figure: Using a variable macro to call up the value of 1 instance of the repeated variable.
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.
Figure: ORDINAL used with a counting variable.
Figure: ORDINAL used with a counting variable example in Preview Mode.