To solve you will want to go to the data tab: create a data type called order, add a field to that data type called āorder no.ā and set this field type to be a number.
Now in the workflow section when you create a new order, define a field order no. = insert dynamic data
do a search for orders:count + 1
This will ensure the order count gradually increases by 1
Thank you for this tip, @evanlitttle ā this is just what I was looking for. Basically instead of a completely random string, I needed an auto-incremented, yet unique, number series and this solution helps get that.
However, while I was thinking about this further, Iām envisioning a scenario wherein if items are deleted from the database, for whatever reason, then this approach will generate conflicting numbers since itās based on count. For e.g. if I have 14 items in my database, then adding a new product gives me products:count + 1 = Product ID = 15. But if I end up deleting a product from my database table (from somewhere in the middle of the table), then Iām back to having a total count of 14, and the next Product Iāll add will be assigned the number 15. Is there a workaround to this particular scenario using the approach you mentioned?
You can create a new data type with a number field that doesnāt get deleted and gets updated every time you add a new product.
Create a number field on the product data type to track the number, then update the last product every time you add a new product or delete a product. Example, if the field is called āatn(all-time number)ā, and you currently have 10 products, then you add item 11. Search for the last product and increase atn by 1. In case you delete item 11, search for the last product(product 10), increase atn by 1 again, to make it 11.
Donāt truly delete a product, but create a field that tracks active products. So deleting the product workflow would not delete it but make it inactive.
If you think youāll have a large amount of products, storage could eventually be an issue for option 3. Option 1 could be a little bit easier to keep track of storage-wise. You could always start from option 3 and go to any other option at any point. Option 2 would require you to configure your search in a way to grab the last known atn.
Better yet build the increment function into a new thingtrigger. That way you are guareenteed no matter which workflow adds a new thing it will always increment and populate the field.
The old school RDBMS way of doing this is to have a system thing containing high water marks, say System High Water Mark. This thing contains at least two fields:
Referenced Things Name which contains the name of the thing that you want to track the high water mark of
So Far which contains a number tracking the high water mark so far of the thing.
Every time you add a new thing to the things you are auto-incrementing you look up the So Far by NAME of the thing and add one to it. Then store that value both in the increment field of the thing you are creating and in So Far.
I found this because I was looking to solve the same problem.
The way I am going to work on it is to create an order number field in my order data and add the first order manually.
Then when the second order comes in, I am going to look up the last orderās order number +1 and write it to the order number field.
In this way if the data behind it gets deleted it shouldnāt mess things up.
In my case, because the āorder numberā is also specific the customer, Iāll set a workflow up when the customer is created to hardcode their first order number and subsequent orders will follow the above.
I havenāt built this, and Iāve been using bubble for like, 13 hours lol. So if this seems like it wonāt work just let me know (orā¦ if I find out it wonāt workā¦ Iāll be back!!)
does this still work? I am a total bubble noobe, and I canāt figure out how to insert dynamic data or where to do that. Am I in the right area here in the attached image.