# Unique ID Generation

**URL:** <https://forum.adalo.com/t/unique-id-generation/22013>\
**Category:** Get Help\
**Created:** [January 13, 2022, 10:13pm UTC](https://forum.adalo.com/t/unique-id-generation/22013 "2022-01-13T22:13:53Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![Victor](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/victor/32/2054_2.png) [@Victor](https://forum.adalo.com/u/Victor)\
**Post date:** [January 14, 2022, 4:14pm UTC](https://forum.adalo.com/t/unique-id-generation/22013/21 "2022-01-14T16:14:11Z")

</div>

@Bobby for number type properties, “Maximum” returns the maximum value from all properties in the collection.

Best regards, Victor.

---

<div class="post-metadata">

**Author:** ![Bobby](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/bobby/32/14843_2.png) [@Bobby](https://forum.adalo.com/u/Bobby)\
**Post date:** [January 14, 2022, 4:19pm UTC](https://forum.adalo.com/t/unique-id-generation/22013/22 "2022-01-14T16:19:10Z")

</div>

Ok, that’s what I thought.

That could technically return the a duplicate result too then couldnt it?

For what it’s worth ive already found a solution to my problem but if anyone comes back and reads this, just to have some clear info 🙂

My solution was; since I made “username” a unique field i just took the logged in users - username and added a RAND number to it.

---

<div class="post-metadata">

**Author:** ![Victor](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/victor/32/2054_2.png) [@Victor](https://forum.adalo.com/u/Victor)\
**Post date:** [January 14, 2022, 4:21pm UTC](https://forum.adalo.com/t/unique-id-generation/22013/23 "2022-01-14T16:21:40Z")

</div>

Well, if you add +1 to Maximum - how will it return duplicate result? 🙂  
I’m not talking about “race” conditions, when 2 users are added at the very same moment of time. Usually this is quite rare case in most of scenarios.

Great that you’ve chosen the solution which suits your needs best!

Best regards, Victor.

---

<div class="post-metadata">

**Author:** ![Bobby](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/bobby/32/14843_2.png) [@Bobby](https://forum.adalo.com/u/Bobby)\
**Post date:** [January 14, 2022, 4:23pm UTC](https://forum.adalo.com/t/unique-id-generation/22013/24 "2022-01-14T16:23:10Z")

</div>

Cant the maximum be reduced if the number of users are reduced? Or is this a count of all users that have ever been created?

---

<div class="post-metadata">

**Author:** ![Victor](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/victor/32/2054_2.png) [@Victor](https://forum.adalo.com/u/Victor)\
**Post date:** [January 14, 2022, 4:27pm UTC](https://forum.adalo.com/t/unique-id-generation/22013/25 "2022-01-14T16:27:55Z")

</div>

It’s not a count, it is maximum.  
E.g. you have a collection with ID property, ID is numeric.  
You add a record and set ID to 999.  
You add another record and set ID to 1.  
When you use “Count”, you’ll get the value of 2.  
When you use “Maximum”, you’ll get the value of 999.

If every time you add a new record, you put ID as Collection → ID → Maximum +1, then you will always have a higher value in a new record.  
It works with all collections, not just Users.

There is a slim chance that 2 app users will add records to the collection _at the same time_. With this you may end with two similar IDs. But again, the chance is quite low.

I’d say that personally I’d go with unique ID generated based on 2 large random numbers 🙂

Best regards, Victor.

---

<div class="post-metadata">

**Author:** ![charleshope](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/charleshope/32/25088_2.png) [@charleshope](https://forum.adalo.com/u/charleshope)\
**Post date:** [January 14, 2022, 6:45pm UTC](https://forum.adalo.com/t/unique-id-generation/22013/26 "2022-01-14T18:45:32Z")

</div>

What do you mean by not allowed?

It works on my app with no issues creating those IDs.

---

<div class="post-metadata">

**Author:** ![Bobby](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/bobby/32/14843_2.png) [@Bobby](https://forum.adalo.com/u/Bobby)\
**Post date:** [January 14, 2022, 6:47pm UTC](https://forum.adalo.com/t/unique-id-generation/22013/27 "2022-01-14T18:47:28Z")

</div>

Sorry, not allowed for my application. I can only have alphabetical and numerical characters for what I use the ID for. Adding the date and time field includes things like colons.

---

<div class="post-metadata">

**Author:** ![paulh](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@paulh](https://forum.adalo.com/u/paulh)\
**Post date:** [January 14, 2022, 7:48pm UTC](https://forum.adalo.com/t/unique-id-generation/22013/28 "2022-01-14T19:48:53Z")

</div>

If you set a date on a non date field, it will be stored as a number…

---

<div class="post-metadata">

**Author:** ![Bobby](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/bobby/32/14843_2.png) [@Bobby](https://forum.adalo.com/u/Bobby)\
**Post date:** [January 14, 2022, 7:51pm UTC](https://forum.adalo.com/t/unique-id-generation/22013/29 "2022-01-14T19:51:55Z")

</div>

No, it still adds the colon as well as hyphens.

![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/3/3fabbe0d09db110a9eceb2164610f9a8aab99254.png)

---

<div class="post-metadata">

**Author:** ![paulh](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@paulh](https://forum.adalo.com/u/paulh)\
**Post date:** [January 14, 2022, 7:59pm UTC](https://forum.adalo.com/t/unique-id-generation/22013/30 "2022-01-14T19:59:43Z")

</div>

Even if it’s a numeric field? I’m not in front of my computer but I know that’s how I do it and it’s definitely numeric

---

<div class="post-metadata">

**Author:** ![Bobby](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/bobby/32/14843_2.png) [@Bobby](https://forum.adalo.com/u/Bobby)\
**Post date:** [January 14, 2022, 8:02pm UTC](https://forum.adalo.com/t/unique-id-generation/22013/31 "2022-01-14T20:02:58Z")

</div>

So, yeah. I guess if the field is a number field it puts out a number, but has a period in it and that is not a character I can use.

---

<div class="post-metadata">

**Author:** ![charleshope](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/charleshope/32/25088_2.png) [@charleshope](https://forum.adalo.com/u/charleshope)\
**Post date:** [January 15, 2022, 10:34am UTC](https://forum.adalo.com/t/unique-id-generation/22013/32 "2022-01-15T10:34:06Z")

</div>

The formula I use is used on a number field.

By multiplying Current Time by 1000000 and using the round function, you end up with an integer with no decimals.

Then adding the random number between 1 and 1000, and you have a unique ID.

The formula works and the result is an integer with no decimals.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/system/32/40401_2.png) [@system](https://forum.adalo.com/u/system)\
**Post date:** [January 25, 2022, 10:34am UTC](https://forum.adalo.com/t/unique-id-generation/22013/33 "2022-01-25T10:34:56Z")

</div>

Closed on January 25, 2022, 10:34am UTC

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.

[Previous page](https://forum.adalo.com/t/unique-id-generation/22013.md?page=1)
