Using a choice filter on an entity list with blank property values

1. What is the issue? Please be detailed.
Hello! I'm trying to use the instance function to filter an entity list in a select_one question. I would like the user to only be able to select entities where a particular text property value is null (or perhaps "" ?). The problem seems to be that the choice filter simply doesn't do anything and all entities are able to be selected.

2. What steps can we take to reproduce this issue?
The following does not seem to filter my entity list when entered as a choice filter in xlsForm standard: instance("entity_list")/root/item[entity_property=""]

3. What have you tried to fix the issue?
I've tried [entity_property=null] but this results in an error during form publication on Central. Beyond this, I'm out of ideas.

1 Like

Hi @Jason_McLellan and welcome here :slight_smile:

To filter a choice list, even an entity list in a select question, you should simply use this logical test in the choice_filter column :

entity_property != ''

The choice_fliter needs a test that returns true or false
Your instance lookup returns an entity, not a boolean value

2 Likes

I believe this is a bug in Collect which I also ran into recently. I haven’t had a chance to try this yet but I wonder whether string-length(prop) = 0 would work.

I’ll try to look more deeply into the source of the issue soon.

I had success with this approach. I didn't realize you could directly refer to an entity property without using something like the instance function. The only modification was that I used double quotes for the empty strings I was looking for. Thanks!

Oh, I’m sorry for misunderstanding, thanks for getting it right, @mathieubossaert!

Am I now understanding correctly that you were putting the whole instance expression in the choice_filter column? And that when you used property=“” in the choice_filter you got the desired behavior? I think the issue I experienced might be limited to properties that don’t actually exist.

The choice_filter column gives a convenient way to write just the expression in square brackets, the filter, when filtering selects. You’re absolutely correct that they’re connected.