Cannot use pull_data, search() and choice filter in the same form

In one form I need to use
(1) cascading select for one question, then
(2) a dynamic select from a csv file (search()) and
(3) select data from that file using pull_data.

I can make each two of them working together but never three. When I have pull_data and cascades working, simply adding definition of cd.csv for search() function

list name, name, label
cd, cd_key, cd_text

into choices sheet causes an error while converting with xls2xform

Traceback (most recent call last):
  File "/Users/mix/anaconda3/bin/xls2xform", line 10, in <module>
  File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/", line 177, in main_cli
  File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/", line 49, in xls2xform_convert
  File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/", line 915, in print_xform_to_file
    raise error
  File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/", line 911, in print_xform_to_file
  File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/", line 771, in _to_ugly_xml
    return '<?xml version="1.0"?>' + self.xml().toxml()
  File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/", line 198, in xml
    node("h:head", node("h:title", self.title), self.xml_model()),
  File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/", line 496, in xml_model
    model_children += list(self._generate_instances())
  File "/Users/mix/anaconda3/lib/python3.7/site-packages/pyxform/", line 472, in _generate_instances
    raise PyXFormError(msg)
pyxform.errors.PyXFormError: The same instance id will be generated for different external instance source URIs. Please check the form. Instance name: 'cd', Existing type: 'pulldata', Existing URI: 'jr://file-csv/cd.csv', Duplicate type: 'choice', Duplicate URI: 'None', Duplicate context: 'survey'.

My cd.csv:

cd_key	cd_text
A16.9	Tuberculosis
T14.1	Animal bite

and simple form:

that contains
pulldata('cd', 'cd_text', 'cd_key', ${disease_selection})
and unrelated cascading select using choice_filter.

Removing choice_filter also allows form to compile.

What am I doing wrong? I realise that I can use a search() for cascading select with external data, which I'll do for now, but would like to understand why it doesn't work: is it by design, or a bug?


Hi @mixmixmix
we can't access your form, please attach it here or give permissions to your google sheet.

1 Like

Sorry about that... Should work now, also uploaded: test_cd_form.xlsx (53.3 KB)


I think it works: (1.3 KB)
I just removed the second row in from your choices sheet (it was redundant) and added a note to display the result and it seems fine.

Sorry @Grzesiek2010, I think I oversimplified. The second row of my choices sheet is necessary for doing selection with search() from external csv, for instance:
select_one cd disease_selection "Select from csv:" search('cd')
(I just added that to the linked spreadsheet).

I wanted to show that adding this correct line to choices sheet breaks the compilation:

list name	name	label rs																				
cd	cd_key	cd_text		

It must be a bug, right?

Your csv file should have the same column names as described in
list_name, name, label not cd_key cd_text

1 Like

This is a known bug tracked at If someone would like to take this on, I think it is approachable to newer pyxform contributors.

1 Like

Thanks @Grzesiek2010 and @LN! Another workaround that I ultimately used is to have all cascading lists using external CSVs.

1 Like