Change or create new when you click submit

Hello, I have tried a lot of different ways but not having much luck. It has got to be simpler than this:
I have an input form with a lot of different fields. One of them is “SKU” which is a unique identifier (there should only be 1 sku number in the data)
When a user clicks submit, I would like the system to either update the “thing” that has that sku number, or create a new “thing” if it does not exist.
How would you approach it?

Hi there, @Baconslayer… one way you could approach what you described is to have two workflow events (events, not actions within the same event) associated with clicking the submit button. One of the events would have a condition on it so the event only runs when a count of items with the SKU is greater than 0, and the other event would only run when a count of items with the SKU is 0. The first event would have an action in it that makes changes to the item with the SKU, and the second event would create a new item.

A question that does come to mind, though, is what is the ideal user experience for your app? I mean, it seems kind of odd that the user is entering a SKU that may or may not already exist in the system, and they aren’t necessarily sure if an item is being updated or if a new item is being created. If it doesn’t matter one way or the other for your app, then what I have described above could work just fine. If it does matter, then you probably want to give the user a way to search for existing SKU’s and make changes to them while the action of creating a new SKU is an entirely separate action.

Hope this helps.


Brilliant, it worked. Still learning all the states and the order to put them in.

For the user experience, I am using the same form to enter and edit skus. So if someone clicks the edit button, it puts all that data into the form - allowing the user to edit it. Also, since there is so much data to create a sku, this allows the ability to clone it and only change the data within it.
There is probably a better way to complete it, but I am day #3 using bubble and without prior programming knowledge :slight_smile:

If you are using the same form for creating and editing, there is a better way than doing the searches I described. If the user is editing a SKU, send the SKU’s associated item to the form, and then you know an item is being edited because the form’s item is not empty. If it is empty, you know you are creating a new item.