[Solved] Dynamic Search(), faster load times than placing choice list on choices tab

1. What is the problem? Be very detailed.
I have four select_one options in my survey. They are Reg, Prv, Mun, and Bgys. After adding the list for Mun and Bgy, testing on ODK collect started lagging(slow) a lot.

I have heard that you can lessen the loading time using csv or external selects, but I do not know nor understand how to do it..

2. What app or server are you using and on what device and operating system? Include version numbers.
ODK Collect, Google Drive xls as server; android phone

3. What you have you tried to fix the problem?
I have tried external select, but for some reason, the choices doesn't appear on Collect.

4. What steps can we take to reproduce the problem?

  • I added Reg-Prv-Mun-Bgy lists on external_choices tab
  • downloaded xml and csv from the odk-converter https://getodk.org/xlsform/
  • updated the xml beng used to download updated forms on Drive
  • searched on the android phone the main folder of my survey form, and pasted the csv file there.

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

Hi @Neko_Acedia,

did you took a look at https://xlsform.org/en/#pre-loading-csv-data ?

Hi @Neko_Acedia, here is just an additional link to checkout https://xlsform.org/en/#external-selects

1 Like

Choices for prv/mun/bgy are in external_choices and choices for reg are in choices.

image

Enteko shows this.

image

I download Xform and CSV; Xform to drive directory, and CSV to my phone form-media folder.

For some reason, selections for province does not show up in collect...

So what am I doing wrong?

I have already tried select_one_from_file itemlists.csv, and it is working, but is as slow as when I just placed all the choices in the choices tab.

Hi @Neko_Acedia

I have used forms with thousands of records in an external csv file and they are usually quite fast (they might only take a bit of time the first time the form is launched and the csv preloaded).

I would suggest you try:

  1. to create unique codes for the different geographical levels. This way you would not need to apply multiple conditions to filter the options for the lower levels. Using codes instead of names could avoid duplicates.
  2. use type select_one and search() function in appearance. Idk if this is faster by design, but it usually works well for me. And, together with the previous point, you would not need to have choice_filter

I hope this helps!

Best,
Andrea

Hello! Thank you for the suggestion, I will check search() function out.

I would like to ask, can this be used with cascading selects? and how?

Yes,

You can use the option 'matches'.

Syntax is:
search('supportfilename','matches','field_in_csv',${variable_of_upper_level})

See sample file attached sample_dynamic_search.xlsx (31.9 KB)
You would use this in combination with a csv that has 4 columns (or more), including: dis_id, chi_id, sec_id, loc_id
The district selection is a simple search in the external file.

The other levels filter the choices based on the previous selection.

Other options for the second argument, are:
'contains'
'startswith'
'endswith'

I hope this helps!

Best,
Andrea

You should find more information about those functions here : Looking for an old documentation page about search() function

If your csv file is big, consider using the "_key" suffix to name the columns to force index creation on the mobile side.
Check the pre-loading data section of this page : https://xlsform.org/en/#pre-loading-csv-data

Thank you, it works!