XLSForm / pyxform

A Python package to create XForms for ODK Collect.
BSD 2-Clause "Simplified" License
77 stars 134 forks source link

select_one_external only works if choice_filter is not empty #488

Closed qlands closed 3 years ago

qlands commented 3 years ago

PyXForm crashes with a key error if select_one_external does not have a choice_filter

  File "/home/cquiros/data/projects2017/personal/software/pyxform/pyxform/xls2json.py", line 1205, in workbook_to_json
    new_json_dict[constants.CHOICES] = choices[list_name]
KeyError: 'counties'

If I correct the code to allow empty choice_filter then ODK Collect crashes with message "Error Ocurred length=30; regionStart=0; regionLength=-1"

I also tried by having a filter column called my_filter and set all items to 1 and then using in "choice_filter" my_filter=1 . But this ended in an empty select in ODK Collect.

Using PyXForm 1.2.1 and Master ODK Collect 1.28.4

lognaturel commented 3 years ago

~Thanks! I believe this may be related to https://github.com/XLSForm/pyxform/issues/387~ I’m now remembering that this is expected behavior. The first select in a cascade with select_one_external is intended to be built into the form. This assumption goes deep in the Collect implementation — the way an external select is identified is through a query attribute. Perhaps you would be better served by the search() appearance/function if your use case requires a first level of a cascade using an external file.

External data is unfortunately in a messy state.

qlands commented 3 years ago

OK. Cool.