Unique ID for each new data type/thing

Hi Guys

When creating a new thing, how do I go about creating a unique ID for it, so that the thing can be displayed according to that ID. Preferably the ID would be in the form of an invoice name that increases by 1 each time a new thing is created e.g. mycompany0001 then mycompany0002 etc

Thanks in advance

1 Like

You can use Do a search for:count to get the count of those Things, and set a field to that number+1.

@deadpoetnsp does this create an ID number or it just lets you search ?

Ok let me break it down.

  1. You can create a field, say, MyUID, in a Thing
  2. When you create a new Thing (of that Type) you want to set MyUID to an increasing number, say index1, index2, and so on
  3. in other words, when you make the second thing, you want the index n to be the same as the count of the Things right before the new Thing is created + 1
  4. “Do a search for [type of Thing]:count” gets you the count of that type of Thing in Bubble
  5. So when you create a new Thing of type X, in the workflow, set the field MyUID of that new Thing to [prefix+] Do a search for [that type of thing]:count
  6. accordingly, the first Thing’s MyUID will become [prefix]+[0+1] = prefix1; there second Thing’s MyUID will become [prefix]+[1+1] = prefix2, and so on
  7. you don’t need to use a prefix and can instead store a numeric id
  8. Subsequently, you can use the MyUID field of that Thing to search, sort, retrieve by index, etc
1 Like

Thanks man, I appreciate the breakdown. Will implement this tonight.

Please note: while the above suggestion points in the right direction, it is not complete and reliable. Please see the following thread for a detailed discussion of how to do this reliably and without collisions in Bubble:

2 Likes

Thanks Keith, will go through this thread as well before starting

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.