Unique code for a product

Hello!
how can i create a specific unique code for each product, in input form like “PROD 452-30-05” and automatically verified if duplicated or not ?
Thanks for your help.

Do you need to create this code by yourself? Because Bubble already creates an unique code for each database entry.

But, answering your question, you can create a workflow to run when your input is updated, searching for it’s value in your database.

yes, i need to create this code by myself, its alphanumeric code to specify each article, would you mind giving more details on how to create a workflow
Thanks

What you can do is:

  1. Create a custom state in your page called “Checked” (type YES/NO);
  2. Open your workflow tab and create a new workflow as below:

image

  1. In this workflow you just need one action, wich is SET STATE OF AN ELEMENT; and choose the state “Checked”.

  2. In the expression you will need to do a Search for Products where the CODE is equal to your input’s value. If the first item returned by this search is empty it means that you don’t have other product with this same CODE.

Search for Products:first item is empty

  1. Make your button (I assume you have a button to create a new product) not clickable by default and in its conditional tab, make it clickable when your custom state “Checked” is YES.

thank you for your help, I’m very grateful

1 Like