Use uuid instead of RAND for ids!

Thank you @Victor for the pointer here in a previous thread

We ran into an issue with our app where we started seeing the same IDs show up multiple times unexpectedly in our DB. These IDs were generated with the RAND(0,99999) function in Adalo magic text/formulas.

Turns out that all these entries with duplicated ids also had the same created_at timestamp. My hunch here is that the random number generator is using the created_at time as the seed.

We are now using the M30 API to generate shortids, like Victor mentioned. Thought I’d share in case others are running into this issue, and I second the call to upvote the request to make record_ids visible within the Adalo UI.

(edit: here’s a screenshot of my data with the repeated ids / timestamps)


Hi @hilary ,

Another alternative would be to use App Settings as tracking number of last ID given, so when new ID is needed, it can be assigned with last ID+1.

I have an example in PSABH series for App Settings, it was Last Order number example.

Hi @hilary
You could also use this method to get the real id of the record itself.

The method works for all collections, not just USER.

We need the item to be created within Adalo so we can pass that new item to multiple pages and continually update it, but I agree that your method seems useful for other cases.

Would that be safe for multiple items created concurrently? Our issue is that the records had the exact same timestamp. The API call is super quick and very reliable as far as I can tell

I have never done stress test about this, but this is using internal update action with already opened linked data, so technically it should be faster.

If you don’t care about sequencing, you can use timestamp as random id, by multiplying first with large number such as 10,000,000 as date time is simply a number.

I think we keep missing each other here… each of my entries had the exact same created_at timestamp, so that solution wouldn’t work.

Not as “No Formatting”, but as number, you can add another number field and do update action with timestamp, and see its content.

I don’t see how that would change anything if they are the exact same timestamps for each of the items (as displayed in my screenshot) – even if I change them to the number format, they will be the same number. I like the solution I have implemented above and was just trying to share the edge-case I ran into in case others did as well. No need to continue the convo.

1 Like

Hi Guys,

Just saw this topic! :man_facepalming:

First of all thanks @hilary for creating this topic! Useful Information!

Just thought to add another two more options that you can generate Unique ID’s!

  1. Using the Randomizer component in the Marketplace!

  1. Another API that made by Abracadalo ( @Abracadalo )! You can find it here! ( Random API section > UUID! )

Thank you

1 Like

Thank you!!! Super helpful to know about the Randomizer!

1 Like