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. Click on 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.
- Click the dashed/dotted arrow above 'New Input'. Then, click '...' 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 '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 click '...' 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.
- Select the '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 '+' 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, click 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'. 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 '+' 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, therefore, we do not need to change 'REDIRECT TO'. 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 click '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 β+β on the βcurrent client' Value. 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.
π― 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).