# Add auto generate unique serial number

**URL:** <https://forum.getodk.org/t/add-auto-generate-unique-serial-number/12888>\
**Category:** Support\
**Created:** [April 27, 2018, 5:15pm UTC](https://forum.getodk.org/t/add-auto-generate-unique-serial-number/12888 "2018-04-27T17:15:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tasadduq786](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/tasadduq786/32/3507_2.png) [@tasadduq786](https://forum.getodk.org/u/tasadduq786)\
**Post date:** [April 27, 2018, 5:15pm UTC](https://forum.getodk.org/t/add-auto-generate-unique-serial-number/12888/1 "2018-04-27T17:15:48Z")

</div>

Dear ODK Team,

I want to add logic/restriction on number filed that automatically generate unique serial number started from 1 using ODK form builder.  
Please guide me..

Will be very greatful to ODK Team.

Regards,  
Tasadduq Husssain

---

<div class="post-metadata">

**Author:** ![tasadduq786](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/tasadduq786/32/3507_2.png) [@tasadduq786](https://forum.getodk.org/u/tasadduq786)\
**Post date:** [April 28, 2018, 4:13pm UTC](https://forum.getodk.org/t/add-auto-generate-unique-serial-number/12888/2 "2018-04-28T16:13:32Z")

</div>

Any one suggest solution to add unique sequence number in my form using odk Form Builder..

---

<div class="post-metadata">

**Author:** ![yanokwa](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/yanokwa/32/1695_2.png) [@yanokwa](https://forum.getodk.org/u/yanokwa)\
**Post date:** [April 29, 2018, 6:27pm UTC](https://forum.getodk.org/t/add-auto-generate-unique-serial-number/12888/3 "2018-04-29T18:27:36Z")

</div>

With an offline system, you cannot generate an incrementing serial number because you cannot talk to the other devices in your campaign to ensure uniqueness.

If you want a truly unique serial number, each form already generates a unique [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) that's available at meta/instanceID. It's a very long large number (e.g., `uuid:9a1d5ce2-e09d-48d4-96f8-21c223eef304`) to ensure uniqueness.

If you want to have some incremental counter that only works on one device, then try the ODK Counter app which does that. [Incremental counter](https://forum.getodk.org/t/incremental-counter/9229) has more.

If you want some human-readable and probably unique ID, then you'll have to make your own from data in the form (e.g., district\_id + head\_of\_household\_name + enumerator\_id + todays\_date).

---

<div class="post-metadata">

**Author:** ![jyaste](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/j/ecd19e/32.png) [@jyaste](https://forum.getodk.org/u/jyaste)\
**Post date:** [July 20, 2018, 8:50pm UTC](https://forum.getodk.org/t/add-auto-generate-unique-serial-number/12888/4 "2018-07-20T20:50:38Z")

</div>

As I expected. Thank you very much for the confirmation.  
John

---

<div class="post-metadata">

**Author:** ![Xiphware](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/xiphware/32/2587_2.png) [@Xiphware](https://forum.getodk.org/u/Xiphware)\
**Post date:** [July 20, 2018, 9:55pm UTC](https://forum.getodk.org/t/add-auto-generate-unique-serial-number/12888/5 "2018-07-20T21:55:34Z")

</div>

To add to Yaw, the meta/instanceID is actually just populated via the XPath [uuid()](https://docs.opendatakit.org/form-operators-functions/?highlight=uuid#uuid) function, which you can reuse for your own purposes anywhere you like; eg

`calculate="concat('my unique serial number is ', uuid())"`
