How to create an auto increment line number

Hello all!
I am building an ODK form for a logging company. One key feature is to have the person recording the data on the tablet to issue the person identifying the trees with a number (unique) as they move through the forest doing the inventory.

My challenge is, how do I get ODK (my form) to either; 1. Auto Increment 2. show the next number in sequence and store it.

I hope that was clear - looking forward to any help I can get.

Hi @Roxroy_Bollers!

There may be a more elegant solution than what I'm about to suggest, but I'll throw out a couple of ideas and see what you think makes the most sense for your project, or see what other ideas folks have...

So, the first time I read your post, I assumed you were issuing a number to a person, but then on second read I thought maybe you were issuing a unique number to each tree? So you can correct me on that if I've misunderstood :slight_smile:

First thought: if you know the number of the tree you're starting from, say you enter "tree 100", then could you enter a repeat loop, where you define a variable that simply adds one to the previous number each time the form looped, so on the next loop it would be 101, then 102, etc?

Second thought: could you somehow use "pull data"? This would be more appropriate if you wanted to predefine the numbers in some way. But seems a bit more complex if you just want a simple incremental number.

I'm sure there are other ways to do this, so maybe others have alternate ideas. But if either one of these sounds like it might work for you, let me know and we could figure it out further.

Actually this can be a complex workflow in practice. What if the data entry will be done by multiple staff? Ensuring unique numbering system per user is a lot easier obviously.

Having said that, I can think it can be done by a post-entry protocol using the order of instance submission.

Hope this helps.


Hello Janna,
Thanks for your response. The "First Thought" I may try. However, the "first time I read your post" that is exactly what I need to do. The booker will issue the person spotting the tree a number which they will then write on a tag and placed on the tree as the move along....

I will try that and see how it evolves.

Thanks again.

You may find Problem with auto number useful, especially the description of the external counter app. It can be embedded seamlessly in a form.

Thanks for your tips and help on this all.