How to avoid duplicate entity record from follow-up form?

1. What is the issue? Please be detailed.
Hello everyone,
In order to learn how to use entities through forms, I created a form based on the example provided in the documentation (https://docs.getodk.org/central-entities, add-participant and follow-up participant forms).
In my case, registration and follow-up are carried out in a single form with the following process:

  1. A first question is displayed to define whether a new element is to be registered or followed up (yes or no question)

  2. If the answer is yes, then the fields required to create a new record are displayed for completion (e.g. first name, last name, telephone). The rest of the form is then displayed before saving.

  3. If the answer is no, a search by name is proposed with a list of choices containing the existing entities. After selecting an item from the list, the fields relating to the entity are displayed and pre-filled with the corresponding values (the user can modify them if necessary). This is followed by the other form fields before saving.

Currently, entities are created as many times as there are submissions.
How can I check that the entity exists before creating it?
How do you define an attribute as the entity's unique ID (e.g. telephone number)?

4. Upload any forms or screenshots you can share publicly below.
ADEMAS ODK XLSForm Template v2023.1.xlsx (523.8 KB)

Hi @junior_diawara,

Welcome to the forum! If you have a moment, please introduce yourself in the welcome thread. Thanks for adding a profile photo as well!

You can set up your form to only create the entity if it is new based on the answer to the first question.

In the entities tab of your form, you would add a create_if column with an expression like the one below that can be true or false.

list_name label create_if
point_of_sales concat(${pos_name}, "-",${community}) ${first_visite} = "yes"

We need to add documentation for this "conditional create" case because I can't find a good link to share with you. There is a note about it in a very new XLSForm template on the "Additional columns" hint sheet.

For your other questions...

How do you define an attribute as the entity's unique ID (e.g. telephone number)?

We don't have a way to use other attributes like telephone numbers or other IDs as the unique ID of an entity at this point, but it is something we are thinking of supporting in the future.

I also want to add that in the next few weeks, we will have a new release of Central that will allow followup forms that can update entities, which seems like what you would ultimately like to use this form for. You will be able to have forms like this one that can both update entities and create new entities. That will involve just another change to the entities sheet that we will provide documentation for.

2 Likes

Hi @ktuite ,

Thank you! Ok, I will take a moment to introduce myself. :slightly_smiling_face:

Alright ! I didn't know it was possible to define a condition using the create_if column. In fact, it appears in the "Additional columns" sheet.
This solves part of my problem. Thank you very much!

I'm very happy to know that you're working on the functionality to update entities via a follow-up form. It's going to be great! Can't wait to see it!

Thanks again for your support

1 Like

You may also find some of what I wrote about real-world or natural IDs at Integrating ODK entities in project that has already been launched - #2 by LN to be helpful.

Eventually we will likely make it possible to explicitly specify that an Entity Property represents a natural id. That will allow the system to do things like checks for uniqueness more automatically and make queries faster. For now, though, you can use any column in that way.

1 Like

Hi @LN ,
Thank you for your feedback. Your post is indeed useful to understand how to set a custom ID for the entities