Forum Academy Marketplace Showcase Pricing Features

Format Unique ID Differently?

Is it possible to format the unique ID differently so that it’s not so long?

Is there a way to change the structure of the unique ID so that it follows a standard naming convention/formula?

For example:

Thing A unique ID formatted as: ABC(x) which uses the formula ABC+1 making each unique ID increase by +1 but the ABC part stays the same?

Thing B unique ID formatted as: XYZ(x) which uses the formula to arrive at the ID XYZ+1 (ex. XYZ1, XYZ2, XYZ3 etc.)

I would create a new field in the User data-type called UserID and create my desired naming convention in that field.
Then create some logic which runs when the user signs-up which does something like: (UserID = User.UserID.LastItem + 1)

By the way - I came up with a solution to the design layout problem you had. I left a comment for you on that thread.


Yes that’s a good way, unfortunately, making IDs shorter is not a purely esthetic problem, so it has to be done carefully and takes time.

I’ve got a standard INPUT close to the ‘add flight’ button here which is supposed to create a new ‘flight number’ for a new flight listing:

Which populates currently as the Input Aircraft’s inputted tailnumber +01 and this can be the standard naming convention for new flight numbers.

Where do I input the formula similar to what you suggest above??

I don’t understand that part and think i’ve done wrong by creating the naming convention at the element level vs. the database level… Help.

Bump on this thread… Thanks all.

I’m not sure it’s such a good way.

Wouldn’t it be possible to end up with duplicate IDs if two items are created at the front end very closely in time? This is the timeline:

Let’s say last item is 24
User 1 starts save and workflow 1 requests last item: gets 24
User 2 does the same and workflow 2 also gets last item number: 24
User 1 stores record using number 25
User 2 also stores record using number 25

Unless workflow data operations are atomic?

This is why this problem tends to be solved at the database level. Other such systems like Knack and have auto-increment fields.

Having a setting on database fields that required unique values would be a good start, because at least you would then get an error on the second user submitting. I will submit that as an idea.

I agree with you.

That is why I want it set on another variable which is inputted by the user them self making the “Id” sequence unique to that user.

The unique id can be something as simple as their nickname plus a 1 at the end (nickname1) and each time user creates a Thing, the system uses their nickname (or username, email, other input…) and merely ads a 1,2,3,4 and so on for each entry they make to the database.

This would alleviate the problem you refer too as it would be impossible for any other user to claim that record in the dB as its tied to them specifically.

I just don’t understand where I can configure this or if it’s even possible @emmanuel. ?

You can create a unique id with conditions on creating a things, at the workflow level, but no way to have a different unique id for now.

I’m still having trouble understanding you.

“Then create some logic which runs when the user signs-up which does something like: (UserID = User.UserID.LastItem + 1)”

Where am I supposed to inject a formula like this? I’ve never seen a formula/setup like this anywhere in Bubble yet…

Secondly, @emmanuel you state to create a unique ID which I’ve done (‘Airpool Flight Number’ under ‘flights’) and at the workflow level i’m looking at the below screen:

Where am I supposed to be filling in a formula that uses another user inputted variable/thing and simply ADDS a # to it effectively making a unique ‘record’ as a Flight Number. ???


@JustinC have you managed to solve this problem? Similar to you I want to show users the unique ID of products they enter in a database and allow them to find the products using the ID. However the unique IDs from bubble are way to long to be usable.

I found this open source hashing function that allows to shorten large strings into unique IDs. Was thinking of using that through an API to shorten the bubble unique ID, however haven’t succeeded yet in implementing it. Still new…

1 Like

I have not.

I have tried to get an answer to this on the forum and email but no help received.

In the meantime, you could use mathjs to ask for a random number, round it and call this via the api,99999))

Use the api plugin to make the call

1 Like

thanks, that works!

Hello - Can you explain what the steps are to accomplish this?

There’s also a MathJS plugin now. So you just have to add the plugin and use it by entering the expression : round(random(10000,99999))

1 Like