SKIP AHEAD TO
What do LOOP blocks do?
How to set up a LOOP
What are value types for Output Sets?
Why would I want to add in a label to in my output set?
List of special LOOP syntax
(Beginner) Use case - Displaying inputs from loop iterations in a table
What do LOOP blocks do?
LOOP blocks paired with a LIST variable allow for a set of pages to be run through by the end user a number of times. Therefore, LOOP blocks are commonly used to capture the same type of information multiple rounds based on the size of the paired LIST variable.
For example, let's say you have a LIST that captures the names of the shareholders you wish to enter the shareholder details for. This LIST will be paired to a LOOP block that includes FORM blocks that will capture the same information for each Shareholder added to the paired LIST. A closer look is shown in the example below.
How to set up a LOOP
- Ensure that there is a LIST variable in your App that you can pair the LOOP block to. LIST variables created with MERGE block can also be paired to a LOOP block.
- Drag in a LOOP block and expand the block by clicking and holding onto a corner of the block and adjusting the size by dragging the corner out
- Move page blocks such as FORM blocks into the LOOP block area
- Connect the page blocks inside your Loop to create the workflow for your end user to loop through. See screenshot below
Note: At this stage, your LOOP block will flag errors, but this will be resolved when you reach step 7 - Under “Input Sets” in the Property Editor, click “+ Add input sets” and enter the variable name for a LIST you want to reference and pair to the LOOP block. Add an additional input set per LIST
Note: The paired LIST variable should be the LIST of items that relate to the set of questions in the LOOP block. For example, in the screenshot below, the paired LIST variable is LIST68 which captures the names of the Shareholders where the FORM block inside the LOOP block will capture the Shareholder information per named Shareholder in LIST68. - Now you must capture the end user responses by adding output sets. Click “+ Add output sets”
- Create an Output Set for each variable inside the LOOP block that you wish to capture to reference in other parts of the App or documents.
Notes:
- Each output set can only output the answers for a single input field. This means that all input fields that are certain to be answered in each loop should be given a unique Output Set.
- Output Sets are LIST variables
- At this stage, your LOOP block should no longer be flagging any errors.
In this example, the variables NUM70 and TXT71 will be needed to be captured so there will be a total of 2 unique LOOP Output Sets as shown in the screenshot below:
- In the case that your LOOP block contains conditional variables which are mutually exclusive for example through a YN block shown in the screenshot below, you must group the different variables as variable options in a single Output Set
For example in the below case:
Because two mutually exclusive input fields branch out of the YN block, only one input field can be answered in each LOOP iteration (I.e., either TXT80 or TXT84).
Therefore, you must reference these mutually exclusive fields as variable options in a single Output Set, which will take only the relevant input from each LOOP iteration. - [Optional] Enter a condition to any variable in your output sets created in the LOOP block. If the condition is not met, the variable will be excluded from the collated LIST variable
- [Optional] Add a break condition to allow users to exit the loop without having to go through every item in the paired LIST
Use cases for a break condition include:
a) Scenarios where the LOOP will continue for each item in the paired LIST until a particular LIST item was assessed to meet a particular outcome
b) Scenarios where users can add as many LIST items as they wanted (while going through a series of questions for each item. For example, with a YN break condition to choose to continue to add or stop adding another LIST item
What are value types for Output Sets?
Like the MERGE block, a variable REF allows you to select either the label, or value of a variable to add to the output set.
- Adding a Value: Pulls the end user response to a variable during run time into the LIST.
- Adding a Label: Pulls the variable’s label value (the grey guidance text on a field) into the LIST.
To understand this better, let’s look at the example variable fullName, set up as follows on a FORM block:
If we set up our variable REF to add the VALUE to the Output Set, and during run time the user entered ‘John Smith’ as their full name, the Output Set block will add ‘John Smith’ to the LIST.
If we set up our variable REF to add the LABEL, during run time, the LOOP block would add ‘Input text’ to the LIST.
Why would I want to add in a label to in my output set?
Most of the time, adding in a Value is what we want to do, because we will only need the user's answers such as TXT, radio or dropdown options etc.
The exception to this rule is Checkboxes. The value of a Checkbox is either TRUE (when ticked by the user) or FALSE (when not ticked), so if we merge in the value, our Output Set will show the word “TRUE” or “FALSE”. Most of the time, this isn’t helpful (because we don’t know what is TRUE or FALSE), so we add in the Label value of the Checkbox instead.
Building on the earlier example, we can add in a Checkbox for the user to confirm that they’ve spelt their name correctly:
When we want to add this into an Output Set, we set up our variable REF as follows:
Note: The condition included is optional, but commonly used so that the Checkbox is only merged into the LIST if the user has ticked it.
List of special LOOP syntax
The following LOOP-specific syntax can be used:
Notes:
- The special LOOP syntax marked with an asterisk (*) can only be referenced in pages inside of a Loop.
- Except for LP#_SIZE, Loop syntax can also be used when writing conditions.
Type | Syntax | Description | Syntax Example | Example Result |
Loop Index* | {{LP#_IND}} | This is a counter for the number of iterations an end user has completed inside a LOOP block | {{LP47_IND}} | If the user is completing the first iteration of the Loop, '1' will be displayed in place of {{LP47_IND}} |
Loop Set | {{LP#_SET#}} | The variable reference format for a LOOP Output Set | {{LP47_SET6}} | The LIST generated by a Loop Output Set (LP47_SET6) will be shown |
Loop Size | {{LP#_SIZE}} |
This displays the number of entries in a LOOP block’s paired LIST and, by extension, the maximum number of iterations that Loop can run through |
{{LP47_SIZE}} |
If the LIST used in a Loop Input Set has 4 entries, '4.0' will appear in place of {{LP#_SIZE}} |
Loop Value* | {{LP#_VAL#}} | This displays the nth entry in a LOOP block’s paired LIST, corresponding to the Loop iteration the user is up to | {{LP47_VAL2}} | If the second value of the Input Set is Apple, “Apple will appear in place of {{LP47_VAL2}} |
(Beginner) Use case - Displaying inputs from loop iterations in a table
This allows you to let your end user validate that their answers in the LOOP have been recorded correctly.
Using the previous example of a LOOP block with decision logic, follow these steps to create a confirmation table:
- Connect a Table to the right of your Loop block
- In your Table, enter headings corresponding to the title of input fields that you want to reference
Note: Ensure that the header row option is toggled for the first row. See screenshot below - Under each heading, reference the appropriate Loop Output Set which will dynamically add rows to the table based on the number of values in the paired LIST
As mentioned above, the TABLE block will have enough rows to the number of inputs in paired LIST that captured the shareholder names (I.e., 2 rows for Sarah and Paul each) which will dynamically generate, creating a complete validation table.