I think I’ve read all the threads on this, but I don’t have an answer.
Is there a sequential auto increment, or at least a number generator. For instance for a human readable “order number”
It wouldn’t matter if the number is actually sequential, but it needs to be human readable and unique no matter what. Every time someone adds a record with a form, it needs to have a unique number. I’ve used max number in glide, but sometimes if there are two users trying to do add an order at the same time, they will duplicate. I’ve tried google sheets array formula, but if someone deletes a row, that changes everything with old data.
Is there a way to get a unique number every time one is requested? I’ve even thought about making a sequential number with an external api, that no matter what, when the api is called, it will create the next number, pass it back and save it to the order number column.
The method shown in my tutorial is also subject to concurrency/race conditions, so is probably not suitable in this case.
@Matthew_Saragusa the only way to be 100% certain of avoiding collisions is to delegate the allocation of your order numbers to an external 3rd party. The problem with doing this in Glide is that all calculations happen client side, so it’s always possible for 2 or more clients to come up with the same number independent of each other.
Your API idea should work - as long as the API is maintaining an independent counter. If it’s using anything that comes from the client to generate the number, then you have the same problem.
What I would do in this case is use Make (Integromat). When a new order is created, trigger a webhook from Glide with just the generated RowID as a parameter. Make would then pop the next available order number from the stack (which could be just a simple increment), and then set the order number to the correct RowID via the Glide API. There would be a slight delay with this method before the order number appears, but no more than about 5 seconds.
That’s more or less it, although steps 3 & 4 would be a single step. That is, you don’t do a lookup, you just do a direct Set Column Values call passing the RowID as a parameter.
I can’t speak for Glide Engineering, but I could imagine this would be quite a challenge given the current architecture. What I do know is that Glide is currently beta testing an alternative server-side computational model (I know, because I’m part of the beta test group). If/when this becomes a reality, then things like this I suspect will be a lot simpler to implement.