Hi @cchukwu
I would like to propose an entire different approach to getting this form to work. This will however require that you do some work on your end to customize the form on the cascade selection using the following instructions.
Approach 1: Using search () in the appearance column.
NOTE:
-
This method will only work on the android collect application. The original writeup can be found here (XLSForm Docs).
-
This method does not need you to execute choice_filter for cascade questions since this is done using one of the search functions i.e. matches (see below)
Step 1 : In the XLSForm, within the survey sheet, specify select_one listname or select_multiple listname in the type column (where listname is the name of your choice list) as you would normally do when defining a select_one or select_multiple respectively.
Step 2 : On the appearance column (survey sheet), define the search function as you would desire.
There are five ways you can use the search function:
- contains - this will check and return all the items in the csv column you need but only for rows which the filtration column contains the specified parameter within any part of the text in the filtration column.
- beginswith - this will check and return all the items in the csv column you need but only for rows which the filtration column beginswith with the specified parameter.
- endswith - this will check and return all the items in the csv column you need but only for rows which the filtration column endswith with the specified parameter.
- matches - this will check and return all the items in the csv column you need but only for rows which the filtration column matches the specified parameter in full to the specified parameter.
- You can also use search without any of the four elements, in this case, you will have the entire list without any filtration applied.
Please note for YOUR ISSUE, we are using the “matches” approach and the search without any additional function.
You will define your search in the column as follows:
search (‘nameofcsv’, ‘matches’, ‘filtercolumnincsv’, ${questionnameinxlsform})
In this example, we are using a csvfile known as countriesbyregions to get various lists.
To understand the example, see the structure of the used CSV file.
If you need to use any other appearance style such as minimal, you will need to define it before the search appearance followed by a space e.g. minimal search () or minimal autocomplete search ()
Step 3: On the choices sheet of your XLSForm, you will need to define how your list will be built from the csv file:
- list_name column: specify the name of your choice list as you normally would.
- name column: include the name of the .csv column to use for uniquely identifying selected choices.
-
label column: include the name of the .csv column to use for labelling the choices.
Note: If you wish to include multiple columns in the labels, include a comma-separated list of all columns to include. The name column will be dynamically populated based on the column name you put there, and the label column will be dynamically populated based on the column name(s) you put there. - In your choices worksheet row, you may also include a .csv column name in the image column. If you do, the image filename to use will be pulled from the specified .csv column.
Note: If you refer to image files in this way, you must always upload those image files as media file attachments when you upload your form to the server.
Using our example, the definition in the choices sheets will be as follows (look at our earlier CSV)
Note:
- The contents of the columns within the csv that will provide the contents of the name, must meet all the requirements of creating a name in the XLSForm choices sheet.
- If you need to pull the label for multiple languages, you can still specify the column that provides them using the same approach above.
Step 4: Upload and deploy your XLSForm as normal. Then upload the csv within the media section as shown below
I would suggest you follow the above procedure on the cascade select so that we look at it together.
Regards,
Stephane