I put a choice filter inside a repeat that I was using to filter down a choice list with images to a single item so that it would show a select with a thumbnail, that can be enlarged as a reference view during data collection. This worked in Collect with no issues. (I know the images won't show in Enketo currently as a select one/multiple with a choice filter and big-image doesn't work - open issue - this also had some problems with a choice filter that used an instance lookup)
The choice filter was of the type; name=instance('trees')/root/item[name=${selected_tree}]/tree_height
2. What steps can we take to reproduce this issue?
Put an instance lookup in a choice filter, load form in Enketo
3. What have you tried to fix the issue?
First calculate the value I need; instance('trees')/root/item[name=${selected_tree}]/tree_height
Then reference that calculated field in the choice filter; name=${separately_calculated_tree_height}
This loads in Enketo, choice filter functions correctly. (images don't show as expected). Still functions in Collect.
4. Upload any forms or screenshots you can share publicly below.
n/a
If you add an image column to the choice list for benches, the form will no longer load in Enketo, regardless of whether the images have been uploaded or not.
So you can have a choice filter that has an instance lookup OR images against the choices, but not both. If you need both, you must do the instance lookup separately and use that field in the choice filter.
This is related to my other issue with Enketo and choice filtering with images & big-images, but at that time form loaded but labels were blank (it was a combined or choice filter in that example though)
Looks like this is another rich bug vein. I'm glad you have a work around for now. We're still trying to figure out how to best approach a fix because these problems run deep.
I'll keep mining
Not being able to see the images in Enketo even with the workaround is annoying, but not a deal breaker currently.
Seems most of my issues are around doing things with images!
Tangent for others, creating a filtered select that has image & big-image is a handy way to serve up one to many reference media (without having lots of note fields with images and using relevance to show) that can also be zoom-panned. (It is just a shame that the default render on Samsung is so poor compared to the actual image quality)
@LN I hit this one again, but no instance lookup in the choice filter and this time reading 'toString'. Form again validated, but threw an error when loading in Enketo. Form did load, but was broken with the affected fields and fields unrelated to it having issues.
Error occured during the loading of this form. We do not recommend you use this form for data entry until this is resolved.
Please contact support@getodk.org with the link to this page and the error message below:
FormLogicError: Could not evaluate: /model/instance[@id="ref_list"]/root/item[if( /model/instance[1]/data/grp_start/filter_preexisting !='',level= /model/instance[1]/data/grp_start/level and contains( /model/instance[1]/data/grp_start/filter_preexisting ,category), level= /model/instance[1]/data/grp_start/level ) and if( /model/instance[1]/data/grp_start/record_type ='report',category!='A',category='A')], message: Cannot read properties of undefined (reading 'toString')
previously working:
if(${filter_preexisting}!='',level=${level} and contains(${filter_preexisting},category), level=${level})`
caused error:
if(${filter_preexisting}!='',level=${level} and contains(${filter_preexisting},category) and if(${record_type}='report',category!='A',category='A') , level=${level}) and if(${record_type}='report',category!='A',category='A')
I've since reworked the logic to this and it doesn't throw any errors and appears to function correctly with no load errors in Enketo.
if(${record_type}='report',level=${level} and category='A',if(${filter_preexisting}!='',level=${level} and contains(${filter_preexisting},category), level=${level} and category!='A'))