Auto_unique_number

Try calculate field for Q1 once(random())
then another calculate field for rounding off Q1 to whole number using
round(${Q1}*1000,0)

··· On Friday, May 13, 2016 at 1:12:07 AM UTC+3, A.N.M AL-IMRAN wrote: > > Hello Everyone, > > I am looking for a feature on ODK. Is it possible to have auto-generated > unique number for each transaction on ODK? I am stuck with my new survey > project, where I need unique ID for each submission. > > Thanks > Imran > >

Thanks a lot Mitch. At least I know that there is an unique id that I can
pick as unique identifier for my survey. I did a research based on your
suggestions; however, my technical knowledge is not good enough to resolve
this issue, since previously I have never used any kind of calculations on
my forms. I have tried to apply the formula; however, I am sure I did not
do it right. now it is generating two separate uuid. Is there any way to
truncate the number a bit to make it look better? Here I am attaching one
of my practice example form, It would be so kind of you could help me to
learn how am I going to apply the calculations and avoid having two uuids.

In addition to that I have one more query on data format calculation. How
do I apply formula to convert UTC to LMT. For instance I am in Canada and
would like to convert the UTC to EST.

Thanks once again and best regards
Imran

A N M AL IMRAN (Imran)
Brossard, QC
Canada
Cell: +1 (438) 501 3576

miner_data_collection2.xlsx (12.2 KB)

··· On 12 May 2016 at 20:19, Mitch Sundt wrote:

This is what the uuid is (but it is a string). Unique instance ids are
automatically provided by XLSForm.

The safe definition of that computation would wrap the value with once():

once(concat('uuid:', uuid()))

Note that ODK Collect requires the instanceId to be a string.

See https://en.wikipedia.org/wiki/Universally_unique_identifier

There are too few possible integers in 32-bit numbers (what can be
represented as integers) to guarantee world-wide, all-time, uniqueness.

On Thu, May 12, 2016 at 3:12 PM, A.N.M AL-IMRAN imran3may@gmail.com wrote:

Hello Everyone,

I am looking for a feature on ODK. Is it possible to have auto-generated
unique number for each transaction on ODK? I am stuck with my new survey
project, where I need unique ID for each submission.

Thanks
Imran

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to a topic in the
Google Groups "ODK Community" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/opendatakit/h4tDprHBSYw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Imran,

When it comes to automatic IDs, you can have one that is long and
unique or one that is short but can conflict. The alternative is to
have a manually entered ID that you generate (e.g., house_id+date)
that you can guarantee to be unique.

Device ID + IMEI are likely to be unique across devices, but won't be
unique across form submissions on that device. You can add a timestamp
or a random number to that, but then you might as well use UUID
because they are basically the same length.

If you are using XLSForm, it will automatically generate that UUID for
you, no need to add it to the form. If you are seeing duplicates,
that's why.

Yaw

··· -- Need ODK consultants? Nafundi provides form design, server setup, in-field training, and software development for ODK. Go to https://nafundi.com to get started.

On Fri, May 13, 2016 at 5:41 AM, cyrus karoki karokicyrus@gmail.com wrote:

Try calculate field for Q1 once(random())
then another calculate field for rounding off Q1 to whole number using
round(${Q1}*1000,0)

On Friday, May 13, 2016 at 1:12:07 AM UTC+3, A.N.M AL-IMRAN wrote:

Hello Everyone,

I am looking for a feature on ODK. Is it possible to have auto-generated
unique number for each transaction on ODK? I am stuck with my new survey
project, where I need unique ID for each submission.

Thanks
Imran

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dear Yaw,

Thanks a loot for your suggestions, which was very helpful. I think uuid is
the best solution for unique id, since the chance of conflict is almost 0.

Thank you once again
Imran

A N M AL IMRAN (Imran)
Brossard, QC
Canada
Cell: +1 (438) 501 3576

··· On 13 May 2016 at 01:07, Yaw Anokwa wrote:

Imran,

When it comes to automatic IDs, you can have one that is long and
unique or one that is short but can conflict. The alternative is to
have a manually entered ID that you generate (e.g., house_id+date)
that you can guarantee to be unique.

Device ID + IMEI are likely to be unique across devices, but won't be
unique across form submissions on that device. You can add a timestamp
or a random number to that, but then you might as well use UUID
because they are basically the same length.

If you are using XLSForm, it will automatically generate that UUID for
you, no need to add it to the form. If you are seeing duplicates,
that's why.

Yaw

Need ODK consultants? Nafundi provides form design, server setup,
in-field training, and software development for ODK. Go to
https://nafundi.com to get started.

On Fri, May 13, 2016 at 5:41 AM, cyrus karoki karokicyrus@gmail.com wrote:

Try calculate field for Q1 once(random())
then another calculate field for rounding off Q1 to whole number using
round(${Q1}*1000,0)

On Friday, May 13, 2016 at 1:12:07 AM UTC+3, A.N.M AL-IMRAN wrote:

Hello Everyone,

I am looking for a feature on ODK. Is it possible to have auto-generated
unique number for each transaction on ODK? I am stuck with my new survey
project, where I need unique ID for each submission.

Thanks
Imran

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to a topic in the
Google Groups "ODK Community" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/opendatakit/h4tDprHBSYw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dear Imran,
I myself often use datetime as my id when I need a number format, i.e. string(format-date-time(now(),%Y%m%d%H%M%S%3)). The result will be like 20160506173243556. It includes % of seconds so I do believe it is rather difficult to find the duplicates.
Thien Dao

··· On Friday, May 13, 2016 at 10:36:17 PM UTC+7, A.N.M AL- IMRAN wrote: > Dear Yaw, > > > Thanks a loot for your suggestions, which was very helpful. I think uuid is the best solution for unique id, since the chance of conflict is almost 0. > > > Thank you once again > Imran > > > > > > > > > > > > > > > > > A N M AL IMRAN (Imran) > > > Brossard, QC > Canada > Cell: +1 (438) 501 3576 > > > On 13 May 2016 at 01:07, Yaw Anokwa wrote: > Imran, > > > > When it comes to automatic IDs, you can have one that is long and > > unique or one that is short but can conflict. The alternative is to > > have a manually entered ID that you generate (e.g., house_id+date) > > that you can guarantee to be unique. > > > > Device ID + IMEI are likely to be unique across devices, but won't be > > unique across form submissions on that device. You can add a timestamp > > or a random number to that, but then you might as well use UUID > > because they are basically the same length. > > > > If you are using XLSForm, it will automatically generate that UUID for > > you, no need to add it to the form. If you are seeing duplicates, > > that's why. > > > > Yaw > > -- > > Need ODK consultants? Nafundi provides form design, server setup, > > in-field training, and software development for ODK. Go to > > https://nafundi.com to get started. > > > > On Fri, May 13, 2016 at 5:41 AM, cyrus karoki wrote: > > > Try calculate field for Q1 once(random()) > > > then another calculate field for rounding off Q1 to whole number using > > > round(${Q1}*1000,0) > > > > > > On Friday, May 13, 2016 at 1:12:07 AM UTC+3, A.N.M AL-IMRAN wrote: > > >> > > >> Hello Everyone, > > >> > > >> I am looking for a feature on ODK. Is it possible to have auto-generated > > >> unique number for each transaction on ODK? I am stuck with my new survey > > >> project, where I need unique ID for each submission. > > >> > > >> Thanks > > >> Imran > > >> > > > > > > -- > > > -- > > > Post: opend...@googlegroups.com > > > Unsubscribe: opendatakit...@googlegroups.com > > > Options: http://groups.google.com/group/opendatakit?hl=en > > > > > > --- > > > You received this message because you are subscribed to the Google Groups > > > "ODK Community" group. > > > To unsubscribe from this group and stop receiving emails from it, send an > > > > > email to opendatakit...@googlegroups.com. > > > For more options, visit https://groups.google.com/d/optout. > > > > -- > > -- > > Post: opend...@googlegroups.com > > Unsubscribe: opendatakit...@googlegroups.com > > Options: http://groups.google.com/group/opendatakit?hl=en > > > > --- > > You received this message because you are subscribed to a topic in the Google Groups "ODK Community" group. > > To unsubscribe from this topic, visit https://groups.google.com/d/topic/opendatakit/h4tDprHBSYw/unsubscribe. > > To unsubscribe from this group and all its topics, send an email to opendatakit...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout.
2 Likes

Hi Thien,

I am trying to generate id as per your example. is there any chance to share an example form to see how I am going to use the string.

Thanks,
Imran

Hi all,

you mean like this :

Best Regards

Dear Nader,

I think somehow it generates a single number and I would like to see where to write on a xls form.

Thanks,
Imran

Dear Imran,

do you mean you want an ID like (Instance ID) for your submission

Like (abcd4242-afgh2424-ijkl44)
or (1,2,3,4,5.....).

Best Regards

Dear Nader,

I want to create an ID as described in the message below:
Dear Imran,
I myself often use datetime as my id when I need a number format, i.e. string(format-date-time(now(),%Y%m%d%H%M%S%3)). The result will be like 20160506173243556. It includes % of seconds so I do believe it is rather difficult to find the duplicates.
Thien Dao
But I don't know, where to write that on xls form.

Thanks,
Imran

Hi Imran,

this is the calculation formula for Uinqe ID for submission

if(true, format-date-time(now(), '%Y%m%d%H%M%S'), format-date-time(now(), '%Y%m%d%H%M%S'))

This is the Unique ID Form
Unique_ID.xls (37.5 KB)
Unique_ID.xml (1.0 KB)

Best Regards

1 Like

@A.N.M_AL-IMRAN Can you please clarify what you need this value for and where you hope to use it? As mentioned in the thread previously, each submission already has a UUID. Can you use that? If you really need a date/time stamp, you can use the expression format-date-time(now(), ‘%Y%m%d%H%M%S’) in the calculation column but do note that it will be recomputed every time the form is opened. You may want to wrap it in a once. You can read more about calculations here.

@Nader Both branches of the if do the same thing and only the first one is ever executed so I don't think the if is necessary.

2 Likes

Dear Hélène,

I am just trying to generate a unique id for each submission. And this unique id should not have any - in between and meaningful. Thanks for the once tip.

Regards,
Imran

Dear Nader,

Thanks a lot. Its clear now.

Regards,
Imran

1 Like

Dear Imran,
Please find attached my example form together with explanation for each type of calculation.
Hope it helps you.
Sorry for replying late. I am kind of little busy these days.
Thanks Hélène for reminding of using once() :slight_smile:
RTA_ODKDateTimeCalculation_ThD.xlsx (19.0 KB)
RTA_ODKDateTimeCalculation_G1.xml (18.2 KB)

4 Likes

Any time Imran

You are welcome

Best Regards

1 Like

You are absolutely right Helene about if.

i just make it so Imran can use it if he want to use it within the form

because Submission have an UUID,

Best Regards

1 Like

@Thiendao Wow, that's a really nice form with lots of useful information packed in, thanks for sharing!

You make a very good point about using string() to "freeze" a date/time stamp. Collect saves time in local time+timezone whereas Aggregate converts it to UTC time+timezone.

4 Likes

Dear ODK Forum,

Please help me i needed auto ID for your submission like (1,2,3,4,5.....).

Best Regards

This has been helpful. Thank you