Add auto generate unique serial number

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.

Tasadduq Husssain

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

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 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 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).

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

To add to Yaw, the meta/instanceID is actually just populated via the XPath uuid() function, which you can reuse for your own purposes anywhere you like; eg

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

1 Like