Need assistance to create an incrementing ID field

Hi

I am trying to create a data collection application for a photographer. What we want to do is submit a form for each shot he takes and this form data needs to include the image ID from his camera.

The image ID from the camera automatically increments each time he takes a shot. The general idea is that for the first saved form the image ID field will be blank and he will have to manually enter in the ID. But then for subsequent shots the form should remember the previous ID and should default to the previous ID + 1. This field data, however, should be editable as sometimes the photographer may take a dud shot and therefore may wish to skip the auto increment on by more than 1 by manually overriding the suggested ID.

For this particular use case, the ID incrementation needs to only work locally in order to be robust as there will never be a situation where more then one photographer working on the same data source at the same time.

The sample that I am working on is currently using an Android mobile phone to save data to a Google Sheet online. I have been creating the forms using ODK Build.

I have been researching similar forum topics extensively but could not find an exact solution to my requirements, and I am wondering now if I can use ODK Collect or need to research alternative solutions.

Your assistance would be much appreciated.

Hi @slim,

In ODK Collect each form is independent from the others, so I don't think it would be possible to

while automatically increase the ID.

A possible solution would be to group photo sessions in a single form (1 or more photos), and use the repeat function to loop.

The functioning would be pretty similar to what you described; the photographer would:
i) launch the form for the session;
ii) enter the ID of the first photo
iii) a counter keeps track of the number of loops being added - e.g. calculate==(position (..))
iv) assuming the ID is alphanumeric, but the last digits are numbers, you could use substr() to get the numeric part and then add increase by 1 at each loop
v) the form would then recompose the ID using the appropriate calculate function.

Each form/submission would contain several records, one per repeat loop.
In case of dud shots, a new form should be used. It could be possible to include options to "skip" one or more numbers but they might be a bit convoluted.

This I think would be the simplest approach.
Alternatively you could look into ODK-X.

Btw, I assume that these photos are being taken with an external camera, and not with the phone in-built one. If this is case, I am wondering whether using an external application (e.g. ODK) would be more time consuming than just arranging and tagging the photos from a computer using dedicated software. If what you are interested was just the list of the photos saved in a folder (e.g. SD card), copying and pasting in a text/excel file should do the trick.

I hope this helps.

Best,
Andrea

Hi Andrea_Martin

Thankyou for your reply and sorry it took so long for me to respond.

The camera shot ID is part of a larger form where data is also collected on other aspects. I believe that the workaround suggested, using the repeat function, and saving separate forms for 'dud' shots', will only serve to obfuscate the process further in terms of data processing afterwards, and I am trying to keep things simple.

It is an external camera. I will look into ODK-X now. Otherwise I will ask the end user if they are happy to manually enter the ID every time as a last resort. Thanks.

As @Andrea_Martin states, in Collect each submission is independent so its not (currently) possible to maintain external state between submissions, which would be required for something like an autoincrementing counter. However, it is possible to use an external app to accomplish this (!), which Collect can then query via an external integer widget. There's an available counter app designed for just this purpose, along with instructions how to use it in a form, described here: https://github.com/opendatakit/counter

If you want to try and solve your usecase within the ODK toolset then using something like this is probably your best bet. [caveat: I've personally not played with this myself, yet, but it should do what it says. You may still need to adapt it somewhat for your specific id increment/override scenarios.., but its probably at least worth a look].

2 Likes

Hi Xiphware, I have asked the client if he can free type it in to simplify the design, if not I will check out your solution, thankyou.