Sometimes it is convenient to equip end user answer options with categories to facilitate building conditions. For example, when your conditions depend on a countryโs continent, it can be helpful to look up a countryโs continent in a database. This way, you avoid building one IF-condition for each country to map them to their continent.
This tutorial describes an approach that scales well and is best suited for larger numbers of answer options. For a more lightweight but less scalable approach, see here.
ย
Assign answer options to categories
In this approach, we will store answer options and categories in a database. This is best achieved by using an Excel sheet and uploading it. Then, we will provide these database records as answer options and thus get access to the categories.
-
Set up an Excel file containing the answer options and their categories (as well as an ID). In our example, this is an Excel file with countries and continents.
If you want to ensure your answer options display in a specific order in your Single or Multiple Select node, save it in reverse order in the Excel file (reason is that records in databases are ordered by their last update). For example, if you want them to be sorted A-Z in your node, sort them Z-A in the Excel file. -
In your application, create a new database Continents and countries and upload the .XLSX file to populate it.
If the database with your answer options and categories is interesting for other use cases, too, consider uploading it in a shared package. This way, it will be available to other applications and only needs to be maintained once.If your database needs to be different different for each environment, consider crating an empty database and importing a different Excel file for each environment. -
In your module, add a Read From a Database action. Select the Continents and Countries database and read in the complete database by selecting the READ type Filter records and deleting any filter conditions.
-
Add a new input node Country of residence. It can be Single or Multiple Select. Provide the entries of the Country field in the Continents and Countries collection as answer options by clicking on the three dot icon .
Toggle on the option Display list as a dropdown for a better overview of the available answer options. This will also enable end users to search for their preferred option by typing it in the field. -
Continue building your module. When you build a condition based on a countryโs continent, click the variable field and select the Country of residence variable. Then, click Selected collection item and the collection item variable Continent. In the value field, type the relevant continent for that path.
-
You can repeat step 5 if you build more conditions based on a countryโs continent.
To maintain the database containing answer options and categories (in our example this is the Continents and countries database), have a look at this tutorial on updating existing databases. This way, you can adapt your database when new countries come into being, an existing one seizes to exist, or a continent splits into two.