# How can I update Entities from the same form originally used to register Entities?

**URL:** <https://forum.getodk.org/t/how-can-i-update-entities-from-the-same-form-originally-used-to-register-entities/54907>\
**Category:** Support\
**Tags:** entities\
**Created:** [May 15, 2025, 7:04pm UTC](https://forum.getodk.org/t/how-can-i-update-entities-from-the-same-form-originally-used-to-register-entities/54907 "2025-05-15T19:04:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![EduardoCM](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/eduardocm/32/22032_2.png) [@EduardoCM](https://forum.getodk.org/u/EduardoCM)\
**Post date:** [May 15, 2025, 7:04pm UTC](https://forum.getodk.org/t/how-can-i-update-entities-from-the-same-form-originally-used-to-register-entities/54907/1 "2025-05-15T19:04:12Z")

</div>

**1. What is the issue? Please be detailed.**

I need to update entities (All the data) from the same form that was used to obtain the information, that is, if someone opens the web form and update data even when the form is approved, the entities can also be updated.

**2. What steps can we take to reproduce this issue?**  
I upload an example form that I'm using.

**3. What have you tried to fix the issue?**  
I tried to use the update\_if function

**4. Upload any forms or screenshots you can share publicly below.**  
[update\_entities.xlsx](https://forum.getodk.org/uploads/short-url/jP9MqvxMfRKNmp0RAAODPRBmpFN.xlsx) (51.3 KB)

---

<div class="post-metadata">

**Author:** ![ktuite](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ktuite/32/14766_2.png) [@ktuite](https://forum.getodk.org/u/ktuite)\
**Post date:** [May 16, 2025, 8:06pm UTC](https://forum.getodk.org/t/how-can-i-update-entities-from-the-same-form-originally-used-to-register-entities/54907/2 "2025-05-16T20:06:12Z")

</div>

Hi @EduardoCM!

Thank you for sharing your form! I have modified your form to hopefully create and update entities in the way you need.

[update\_entities\_updated.xlsx](https://forum.getodk.org/uploads/short-url/p0gIw365w3K7WZDPSoDRxuBb3UR.xlsx) (53.9 KB)

Steps:

**1. Add a question to optionally select an existing entity**

In your case, the entity list is called `eventos` so we could have a question like

| type | name | label |
| --- | --- | --- |
| select\_one\_from\_file eventos.csv | evento\_existente\_id | Seleccione un evento existente para editarlo |

This will capture the ID of the existing entity to edit, which we can use to hook up everything else.

If no entity is selected, then the form will create a new entity.

**2. Fill in the default value for each field on the form with the data from that entity. You will need to make a change to every row that has a `save_to` value filled in.**

- Add a `trigger` column and fill it with `${evento_existente_id}`
- Fill in `calculation` for every row with a `save_to` with a formula like `instance("eventos")/root/item[name=${evento_existente_id}]/tipo_evento`

**3. Update the `entities` tab to add rules about how to create or update the entity, and how to identify the updated entity:**

| create\_if | update\_if | entity\_id |
| --- | --- | --- |
| ${evento\_existente\_id} = '' | ${evento\_existente\_id} != '' | coalesce(${evento\_existente\_id}, uuid()) |

The `coalesce` expression is needed for this combined create/update form because the form generates the entity ID. (Otherwise, when a form only creates or only updates entities, this ID is set implicitly.)

**4. For the part of the form where you are saving values from a cascade select, I added `redes_locale` as an entity property so it could be used to look up the values later**

Additionally, when I tried to create and then edit one of these events, not every value was filled in, but I think it is because those fields were just not saved to entity properties and they could easily be added if you definitely wanted to edit them later.

This was a useful exercise for me to do! It was a little tricky even having the [entity quick reference](https://docs.getodk.org/entities-quick-reference/) to refer to. I think it could also be the topic of a mini-tutorial about entities -- how to take a form for creating entities and transform it into a form that can also update them. If there is anything about this form that _doesn't_ work, please let me know!

---

<div class="post-metadata">

**Author:** ![EduardoCM](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/eduardocm/32/22032_2.png) [@EduardoCM](https://forum.getodk.org/u/EduardoCM)\
**Post date:** [May 19, 2025, 1:54pm UTC](https://forum.getodk.org/t/how-can-i-update-entities-from-the-same-form-originally-used-to-register-entities/54907/3 "2025-05-19T13:54:31Z")

</div>

Thank you so much Kathleen for your help, this is very helpful in understanding the power of Entities more deeply.
