Filtering Entites

I am designing a series of ODK forms using entities. I have built an enrollment form and multiple results forms. My entities = list of participants enrolled in the study via the enrollment form. I want to limit my list of participants (entities) on my results forms to only show participants who haven't already completed a results form. Is this possible? And if so, how can I do this?

Thanks!

Hi @Emalee_Martin !

Yes, the aforementioned is possible! You'll have to use "update_if" to update a particular property (a property that keeps a record if that particular entity instance was already used in one of the results form or not) for an entity instance from the results form.

Reference: https://docs.getodk.org/central-entities/#building-a-form-that-updates-an-entity

Example:
Let's say I submitted two enrollment form and the following entities were recorded automatically:

EntityID Label Name Age UsedInReportForm
abc label-abc Name1 25
pqr label-pqr Name2 26

And, then I filled and submitted the results form (the one with update_if configured and enabled) for "Name1" (we had two options to select from - "Name1" and "Name2" with "UsedInReportForm" = ""), the resultant entity table would get updated as following:

EntityID Label Name Age UsedInReportForm
abc label-abc Name1 25 USED
pqr label-pqr Name2 26

When refreshed, the next instance of results form would only display one option to select from - "Name2".

Hope you'll find it helpful! :smile:

Thank you @MinimalPotato ! I am not familiar with the update_if function... could you provide an example? Or direct me to an existing sample? Not sure where to build this into my form and not finding much guidance online!

Thanks!!

Have a look at @LN's example form here

Specifically the entities tab and the create_if and update_if columns
image

The documentation section is this one

1 Like

@ahblake using update_if seems to prevent my entity list from updating... I'm trying to filter my existing entity list.

I tried adding the update_if column to my entity sheet on my Follow-Up form. I had update_if DBSResult = ''. But all that did was prevent my entity list from being updated with the DBSresult. I want to filter the list of entities so that when I start a Follow-Up form I can only select from a list of entities (participants) without an existing follow-up form.

Attached are the two forms: Enrollment and DBS Results:
Enrollment.xlsx (37.3 KB)
Follow-up.xlsx (37.4 KB)

Sorry, that was unclear, I was only responding to provide info on update_if use.

If you wish to filter out completed items, the simplest method would be to have a column in your entity list that gets populated/updated by the followup form, and filter using it. As per @MinimalPotato's example of filtering to only those where UsedInReportForm was blank.

eg a column 'followup_status' in the entity list that starts as null or 'incomplete',
then the submission from the followup form will update that value depending on success/failure (so only successful attempts get filtered out).

You can use this field to filter your entity list (after it's synced, or when offline entities are availalble).

You could also write a new label to the entity list on the entities tab, made up of the original label plus a :white_check_mark:, then not filter anything out, but show the items as either complete or incomplete.

1 Like

I had tried this earlier but decided to try it again and I got the same error. It's not letting me create a new column on the entity list AND use that same column to filter the entity list in the same form.