Create a counter in form

1. What is the problem? Be very detailed.
We need to create a counter in a form, so, the first time the form will be created it will have 1, than, the second time the counter values has to be 2 and so on....

2. What app or server are you using and on what device and operating system? Include version numbers.
we are using ODK collect 1.5, and we cannot upgrade to newser ones... sorry.

3. What you have you tried to fix the problem?
we found the last-saved function, but it seems to not work on our odk collect version... or maybe we didn't use it in the correct way...

4. What steps can we take to reproduce the problem?
load the example form we created

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.
aMAqcrcw9Mkr5Q4k4qR6N7 (2).xml (1.7 KB)

thank you very much

Hi @Angelo_Lazzari1
so you want to have values like 1,2,3 etc for every saved (filled) form. Am I right?

What version are you using?

could you attach the xls version?

Yeah, you are right, 1,2,3 and so on... I would like to put it in a variable and than manage it as I want...

We are using collect app version 1.5 ... I attack the XLS version

thank you very much!

aMAqcrcw9Mkr5Q4k4qR6N7 (1).xlsx (6.0 KB)

1 Like

oh that's a very old version and last-saved was not supported then indeed. Why do you still use such an old version? If you don't upgrade there is no way to fix your problem.

we cannot use another app because we have some tech limitation to upgrade.... thank you very much for your time.
Angelo

please .. tell me the answer i need it ... i found the topic i searched but, in this dialog there is no support solution... if you could help me with this i would be very grateful ..

Hi, did you tried with last-saved ? if you are using the latest versione you have complete support on it... read here https://docs.getodk.org/form-logic/#values-from-the-last-saved-record

hello..thanks for answering.. I know how to use last-saved, but I don't know how to do the programming logic to create a numerical counter for each open form.. you know? do you know how i could do this exactly?

Hello @BrunoAngelo,
you can take a look at this example.
If the id already exists (last-saved is not null), we use it, else we set it to 0, and then we add 1.
Again it will work for only one device. Each device using the form will have its own sequence.
incremental_id_per_device_using_last_saved.xlsx (13,0 Ko)