How to automatically capture a filtered list of entities?

Hello,

I use ODK Central/Collect to capture animal welfare records. That is, collecting records of a human visit to a physical location and recording an interaction with animals such as feeding, verifying water is available and to conduct other husbandry.

I am currently using a 2 form setup, 1 form to track mob movements between paddocks and another to track welfare checks on paddocks 1-many relationship. These records are then combined externally to Central with a python script to match mobs to welfare checks using date/time.

This has some downsides such as no visibility on mob status in Collect and the required compilation of records for analysis and reporting.

New Forms using Entities

The new entities functionality seems ideal for this, I have a staging instance setup with the newest version of central to test entities for this workflow.

Below are my new forms for registering a new mob entity, updating the paddock of an entity and completing a welfare check on a paddock containing entities.
This is a proof of concept so not all fields are included. I currently use a geojson file for paddock polygons, this can be switched to the paddock_list choice list if you don't have a geojson file to substitute. You may also have to remove the parameter value=title if you do this.

Mob Create Entity

Mob Paddock Movement Entity

Mob Paddock Welfare Check

Issue using Entities

I'm struggling to find a way to automatically capture a filtered list of entities in the welfare check form.

In the paddock welfare check form provided I have a select_multiple mobs.csv (entity list) with a choice filter using the user provided paddock name mob_paddock=${paddock_checked}.
This shows all entities/mobs with the user specified paddock name but would then require the user to select all filtered options displayed manually.

Is there some way to capture all filtered entities automatically?

If this was a note field that auto filled that would be ideal to show the user what mobs are in the selected paddock and record them.

Also, using my current select_multiple the entities UUIDs are recorded and not the entity names, is it possible to record all entity names (mob_name) instead of UUIDs?

Thank you for your time, I appreciate any assistance.
Ben

Hello @Ben_Sefton and welcome here!
Thank you for your introduction.
I look forward to reading your future articles. It seems we share some use cases (water infrastructure monitoring and pasture assessment).

If I understand your requirement correctly, you want to filter the options of a select_multiple question based on a previous answer ( -> choice_filter) and then select all those options by default?

Here is something that seems to work fine :
test_default_select_multiple.xlsx (475,8 Ko)

You can also take a look at this showcase : Pre-populating select with default option

1 Like

I think specifying a value column is what you're looking for: documentation.

Hello @mathieubossaert,

Thank you so much, that works perfectly with a note field.

I ended up using this XPath expression
join(',', instance('mobs')/root/item[mob_paddock = ${paddock_checked}]/mob_name)

This automatically filters based on the users paddock selection and saves the names of each mob (entity) if they don't select any of the filtered items.
However, if a user actually selects any of the filtered mobs as a select_multiple question list it only records the mob UUID/s instead of the mob_name/s. To solve this I realised I don't need select_multiple to record multiple entries so I've changed my question type to a note field. This now works exactly as needed, recording all mobs in the paddock and displaying a comma separated list to the user.

@LN Thank you for your suggestion. I've tried using the parameter value=mob_name and value=name but this is not allowed for select_multiple.
Accepted parameters are 'randomize, seed'. The following are invalid parameter(s): 'value'.

Please see my updated form below for reference. I'll make a more detailed post about my new animal welfare records form setup once deployed.

Thank you for your help, it is greatly appreciated! :slight_smile:

1 Like

Ah, yes, it will only work with select_multiple_from_file. You're using select_multiple to make it easier to work out and demonstrate isolated strategies before you eventually switch over to an entity csv, right? That's a good technique. In that context you can copy the same values for name and label in the choices sheet.