Display sample number as unique sample ID

1. What is the problem? Be very detailed.

I am trying to create a unique ID for each entry of biological data. I have a nested form in which level 1 contains vessel specific data such as vessel name and area fished, and level 2 contains biological data for each sampled fish from that vessel.
I would like to display the sample number that pops up in the upper right corner of each level as a concatenated note_id field. The note_id for each biological sample should be 1-1, 1-2, 1-3,... 2-1, 2-2, 2-3 etc... with the first digit being the sample number for the first nested data set and the second digit being the sample number from the second nested data set.

Currently, I'm using a timestamp as the unique sample ID. However, in the web form if I refresh from the cache after accidentally closing out the form the unique sample ID (timestamp) refreshes with the current time and my previous unique sample ID's are lost.

2. What app or server are you using and on what device and operating system? Include version numbers.
I am using xlsforms on a windows tablet with Windows 10.

3. What you have you tried to fix the problem?
So far I have not tried anything as I can't find out what identifies the sample number in the upper right corner of each nested set of questions.

4. What steps can we take to reproduce the problem?

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

you might find this discussion helpful: https://forum.getodk.org/t/auto-unique-number/5523

1 Like

Thank you, wrapping the timestamp in a once() command prevents it from changing each time the form is loaded from cache.
This was very helpful. I would still be interested in using the sample numbers as originally mentioned, but at least the unique ID timestamp is now consistent.

Welcome to the ODK forum, @mdschuster! We're glad you're here. When you get a chance, please introduce yourself on this forum thread. I'd also encourage you to add an image as your avatar because it helps build community!

You can get the index value of a repeat group in order to build sample numbers. Please see the following:

Thanks for the information @danbjoseph. The once() command allowed me to utilize the time stamp feature, concatenated with a single digit location code, which is enough for now. I wasn't able to delve deeply enough into the index value feature to make it work. There's a pretty steep learning curve with this system and only so much time!

Have a play around with this and see if its what you need:
nestedrepeatindex.xlsx (6.0 KB)

The 'secret sauce': concat(position(../..),"-",position(..))

1 Like

This was super helpful @Xiphware. The form is working beautifully.
Thanks!