# Generate sequential ID based on pulled data

**URL:** <https://forum.getodk.org/t/generate-sequential-id-based-on-pulled-data/49408>\
**Category:** Support\
**Tags:** entities, form-design, odk-xlsform\
**Created:** [September 10, 2024, 9:47am UTC](https://forum.getodk.org/t/generate-sequential-id-based-on-pulled-data/49408 "2024-09-10T09:47:52Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![LN](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ln/32/1605_2.png) [@LN](https://forum.getodk.org/u/LN)\
**Post date:** [November 8, 2024, 1:06am UTC](https://forum.getodk.org/t/generate-sequential-id-based-on-pulled-data/49408/8 "2024-11-08T01:06:57Z")

</div>

So sorry about the delay in getting back to this!

You can find @joybindroo's example adapted to use Entity Lists [here](https://docs.google.com/spreadsheets/d/1-Rga1aiFIX5RkGaHcT0aZq-YD7Kh7YSkryVmyNuwolc/edit?gid=1068911091#gid=1068911091).

To try it out:

- create and publish the form
- go to the `households` Entity List add the "household" property. We need to add this one manually because the form doesn't save to it.
- upload [households.csv](https://forum.getodk.org/uploads/short-url/nQwpaGQuzUWoIZ7miSos5Eqwkoi.csv) (99 Bytes) to the `households` Entity List ([docs](https://docs.getodk.org/central-entities/#importing-csvs-into-entity-lists))
- try the form out using a web form or assign the form to an App User to try it in Collect

To see the id update within a single household, you will need to refresh the form in between adding new household members. If you'd like to see updates happen offline, you can try the latest Collect beta with Central v2024.2.0 following the instructions [here](https://forum.getodk.org/t/odk-collect-v2024-3-beta-offline-entities-counter-map-scale/49420/20).

### Example with household and participant Entity Lists

You can find a more complex example using a participant Entity List [here](https://docs.google.com/spreadsheets/d/1TVSr8Z2ANRB1IwD9EmgKCCYZwpJHm24d7kotRWY-_Tc/edit?gid=1068911091#gid=1068911091).

This example demonstrates doing a little bit more participant management by giving the option to archive a participant in addition to adding a new one.

To try it out:

- if you've been experimenting with the form above, you'll need to create a new project for this one because both have a `households` Entity List with a different structure
- create the `households` Entity List ([docs](https://docs.getodk.org/central-entities/#creating-an-entity-list-in-the-central-interface)). This one isn't modified by the form so it needs to be created ahead of time.
- add the following properties to the Entity List you just created: `village` and `household`
- upload [households.csv](https://forum.getodk.org/uploads/short-url/aSgFEGFyZzPMTVqp9WatPunedCt.csv) (736 Bytes) to the `households` Entity List ([docs](https://docs.getodk.org/central-entities/#importing-csvs-into-entity-lists))
- create and publish the form
- go to the `participants` Entity List that was created by the form, add the `village` and `household` properties
- upload the [participants.csv](https://forum.getodk.org/uploads/short-url/v6o7DPIEUdkPYcWMWd9jztYyAok.csv) (7.1 KB) to the `participants` Entity List ([docs](https://docs.getodk.org/central-entities/#importing-csvs-into-entity-lists))
- try the form out using a web form or assign the form to an App User to try it in Collect

⚠ Some things to note:

- The village and households lists feel like they might not be needed. They're convenient for specifying labels, but maybe the ids would be enough. This is the same issue that @TomJ described in [the idea to have a `unique`/`distinct` function](https://forum.getodk.org/t/add-distinct-function-for-use-with-entities/42945)
- If you upload the household and participant CSVs as I created them, their order will look backwards in clients. This is related to [the idea to make Entity List sortable](https://forum.getodk.org/t/sorting-entities-for-use-in-choice-lists/47902)
- There's a lot of computation going on in this form! I would want to try some test data with my target devices if I wanted to use this for more than 20,000 participants or so

I know there's a lot going on in these examples! They were a good opportunity to illustrate several different Entities-related ideas. Hopefully you can take what you find interesting and leave the rest behind.

---

_[View the full topic](https://forum.getodk.org/t/generate-sequential-id-based-on-pulled-data/49408)._
