Authors can use URL parameters in conjunction with Redirect Results to loop through a module without the need to re-enter repeating information. An example use case would be a module that collects client information and writes it into a case database.
A step-by-step guide to looping modules
Follow the steps below to learn how to use databases and URL parameters to loop through modules by building a module that collects client information and writes it into a database.
Configure a case database
- In your Application, select Case Databases in the side menu and click on New Case Database to add a new case database to the Application.
- Create a case database by providing a name for your case database.
- The new database now needs to be configured by adding all the required fields and field types to the case database. Select Configure case database to set up the configuration or schema of your case database.
- When setting up the configuration of your module, we recommend opening both the module and the configuration page in two separate browser tabs or windows. Authors can ensure that they do not forget any value and that the correct type is associated with the field. The identifier (id) of the case record is automatically added and can be renamed by typing into the blue field below Unique Identifier.
- Once all fields have been added, select Save Configuration to save the schema and all the fields. Set up later will not save the configuration but discard all changes.
Build your module
- In your Application, select New Module.
- We will begin by setting up our two URL parameters. One URL parameter will 'store' the value for the maximum number of clients whose information should be entered, while the other URL parameter will 'count' the number of loops, ensuring that the module will repeat until the specified number of loops has been completed.
- Select the dashed/dotted arrow above New Input. Then, select the three-dot menu and Insert Action to add a new Action node. Below the search bar, select Integrations and choose the option URL Parameter. Rename the node by double-clicking and typing out 'maximum_clients'. Copy and paste it into the field Query Parameter Name. Finally, set the Type to Number.
- Add a second URL Parameter below the first URL parameter and above your empty Input node by repeating step 3. Change the name to 'loop_number'.
- Click the arrow between the second URL parameter and the empty Input node, then select the three-dot menu and Insert Value to add a new Value node. Set the Value Node to Number. Rename the node by double-clicking the node name field and typing out 'max_client'. In the field Number, @-reference the 'maximum_clients' node by typing out @ and selecting the correct node.
- Repeat step 5. Change the node name to 'current_client' and in the field Number, @-reference 'loop_number'. In that same field, type out '+1'. It should look like this: 'loop_number+1' with the first part being highlighted in blue color.
- Add a new Input node towards the bottom of your graph. This is the first front-facing node and will serve as your Intro Screen. In addition, this is where the user is asked to specify the number of clients they would like to enter, i.e. the number of loops that should occur. Therefore, after renaming your Node and typing out all relevant information (incl. the request to enter the number of clients) in the Content field, change the node type to Number by clicking Single-select next to the node name field.
- Click the plus symbol (+) on the Input node, then Insert Value to add another Value node. Set it to Number and begin typing out 'max_client' to update the Value. In the field Number, @-reference the Input node above.
- Again, select the +, then Insert Input to add a new Input node. Rename it to ‘Client Information'. This node will collect all client information that is input by the user. As we are asking for a number of different information, set the node to a Multi-Input node. In the Content field, type out all relevant information. For instance, using @-referencing you can let the user know which client number they are currently providing input for. Simply @-reference the ‘current client' and the ‘max_client' Nodes. As for the requested input, refer to the fields you have configured in your case database. In our example, we chose 'Name', 'Company', 'Position', 'Contact number', and 'Email address'.
- Add a new Action node by clicking the + symbol and selecting Insert Action. Below the search bar, click Case Databases and select the database we have set up prior to building this module. By default, the Database Action is set to Read. However, we want to collect and store information, i.e. write information into our Case Database. Select Write. Then, in each of the fields, @-reference the corresponding input from our Multi-Input node. Finally, rename the Action by double-clicking the Name field. We chose ‘Write database'.
- Create two Result Nodes. One Result will serve as a regular 'end screen' to the module. In its Content field type out a short message as you typically would. The other Result Node will finalize the looping. However, to do so we need to change its type to a Redirect Result node. Click Result next to the node name field and select Redirect. We want to redirect to a module. Click the drop-down menu below Select Module, then select the current module. Add URL Parameters by clicking Add parameter. In the left field, below URL Parameter key type out the name of the first URL parameter 'maximum_clients'. In the right field, below URL Parameter value, @-reference the 'max_client' Value node. Then, once again select Add parameter. In the left field, type ‘loop_number', in the right field, @-reference the ‘current_client' Value node. Do not forget to rename the node by double-clicking the name and typing out 'Loop'.
- Finally, we need to set some conditions. Scroll up in your graph and click the plus symbol on the ‘current client' Value node. Then, select New Transition. Choose the Input node ‘Client Information'. Now, click Add condition and set the following condition: 'current_client > 1 '. This will ensure that the Intro screen is shown only once and not repeatedly.
Scroll down to the bottom of your graph and select the Transition from Write database to Loop by clicking the arrow between the nodes. Again, click Add condition and set the condition: 'current_client < max_client '. This ensures that the module will continue to loop as long as the number value assigned to 'current_client' is smaller than the one assigned to 'max_client'. Remember, while the number value to 'max_client' is assigned once and remains constant, the number value of 'current_client' is increased by '1' after each looping.
- Finally, we need to set some conditions. Scroll up in your graph and click the plus symbol on the ‘current client' Value node. Then, select New Transition. Choose the Input node ‘Client Information'. Now, click Add condition and set the following condition: 'current_client > 1 '. This will ensure that the Intro screen is shown only once and not repeatedly.
💯 Advantages of looping through modules
There are several advantages when using databases and URL parameters to loop through modules:
- This solution is particularly elegant as it allows for a compact build using only a limited number of nodes.
- This extends to the end-user interface in a similar manner, as the user is not overwhelmed by repetitive screens (Intro screens) or questions (Would you like to add another client's information?).
- It has fewer limitations than e.g. Collections (Allow multiple responses).