Unique Counter to avoid duplicates

Hi, I have messaged on this a few times now, just reaching out to see if either something has been released by Glide or if anyone else has found an easy way to this without having to use an API as that is my next solution.

I need to create unique ID (counters) for when we create projects, events, users, employees, companies, etc… We tried using the rolloup (MAX) and match (NEXT) logic, however, when we have multiple users (most cases) you get into a race condition, where if multiple people open up the form they will all receive the same ID and we end up with duplicates. Especially bad when we are trying to generate PO and invoice numbers

What we then did was to add a counter in the users profile, and increment that at time of submit, worked fine, or so we thought, over the periods of about 3 months of usage, we came across a duplicate, when we investigated further we found another 700 duplicates out of 13,000 invoices generated. The issue is that these invoices were never billed/sent to the clients for payment, we now have a lot of explaining to do with our own client.

Not sure what happened here, if it was that the same user opened up multiple windows (laptop, desktop, tablet, phone, etc…) or there was some other glitch, but its a major issue.

I am sure others are also doing invoices and have to create unique invoice numbers, how are you doing it. It needs to be an atomic operation of giving you an ID and incrementing immediately, I am surprised that it has not been implemented yet.

My next solution is to create an API for unique counter, where I start a new counter and I am returned a countername and the counter, and after that each time I want a unique ID I just make a call with the countername, it gives me the next number and increments the counter to ensure it never gives out the same value more then once. Just seem a bit of an overkill for something basic/core.

Any ideas ?

One way is to delegate the counter to a third party like Make/ Zapier… an action would trigger a webhook to Make and in the end you write the result back to your database

Yes, we can, but trigging hook costs more than one update, because one for trig and another one to call Glide API(for return response).
Instead call api can return response which don’t cost update.

1 Like

Hi,

Are you referring to the “FETCH JSON” under DATA and APIs ?

FETCH JSON alredy gone

I’m new to API’s and make/zappier. Can’t get this to work yet. Does anyone have a detailed example/template for making atomic increment via zappier or make?

Using Make, you would just maintain a counter in a Data Store. So the process would be something like:

  • Webhook to Make (needs to include the source Row RowID)
  • Read current counter value from Data Store
  • Increment counter by 1
  • API call back to Glide to update row with counter value
  • Save new counter value in Data Store

Is this the process you mean? If yes, would you know the cause of this error?

Well, it’s pretty obvious. A webhook should be the first module in a scenario. If you are trying to follow what I described, you should have a HTTP module there, not a webhook.

1 Like