How to create a thing from a custom state list

How can I save a “custom state” list of a “custom data type” into database? let me explain it.

I have a custom state list called “my_hobbies”, the type of this custom state is a “custom data type” that has the fields: “name, description, image, date”.

I have a form with all the fields with a button “save”. what I want to do is: when the save button is clicked I want to add a new item to my custom state “my_hobbies”.

later when I have more than 5 items on my list… I want to save this list in the database.

I only see basic examples, using text type for the custom states. Also I see that there is something called “schedule workflow”… but I am not sure if that is the correct way to do it

@burgoscervantes what you can do is you can use backend workflow to get the job done. After clicking on save make a list of each field like name, description etc. Then at last when you have your five item you can send this list of each field to backend workflow and from you can create a new things using indexing of list. So basically you can run a loop on this list and store that way in database.
refer to the link - Learn How To Use Backend Workflows In Bubble.io (Part 2) #nocode #bubble - YouTube

2 Likes

For my example, “Backend workflow” is the recommended ways to do it (bubble way) ? or is just a workaround?

Please don’t get me wrong… Thanks for answer. I am just wondering if “backend workflow” is like “using a missile to hit a nail” … I was thinking that create a thing from a custom state list it seem to me something so common that using a “backend workflow” feels strange

Hey @burgoscervantes ,

You have a few options depending on your data structure. The backend workflow is the only way to create a new database record for a list of an unknown size. If you always know that the list will max out at 5 items, then you can just add 5 “Create a new thing” actions in your workflow and be done with it.

Also, since your custom state is a list of a custom type, that means you already have records for something. Creating a new record for each item from there would imply you’re creating a unique relationship between that existing item and the user…? Alternatively, you could add this custom state list value to a single record’s list field (of the same type), and this can be done without a backend workflow. Let me show you the difference between these two because I don’t have full context on what you’re doing:

Method 1 involves 2 data types: Hobby and Favorite

  • “Hobby” is just a table of a bunch of hobbies users can choose from. They’re not specific to users yet.
  • “Favorite” is a data type that links a Hobby with a User. From there, the user may be able to add notes to it, keep track of when it was added as a favorite, etc.
  • If your flow is such that: user selects and unknown number of Hobbies and you want to create a Favorite record for each of those, then yes, you need a backend workflow because you can’t anticipate the number. If you’re fixing things to 5 Hobbies (therefore, 5 Favorites), then you can just add 5 “Create” actions in the page workflow.

Method 2 doesn’t create new records

  • Let’s say the User data type has a list field (type = Hobby)
  • User selects X number and when they click “save”, you run a workflow action to update the current user’s list field. You’d use the “add list” operator to add the custom state list value. No need for backend workflow.

Hope this helps!


Cheers, Gaby
Co-Founder at Coaching No Code Apps
Free Bubble Masterclass
Private Help

@romanmg

My use case is the first one that you describe: a list of unknow item. I have used the hobby example because I didn’t have permission to talk about the project but now I have the permission.

I am trying to create an MVP project for a client. This is the form:

The app will allow users to create a “meet” …So … on the screen, I have this section called “Required Skills”. It is an input that when you press the “add” button, the value is added to a list custom state called “skills” of the type “text”. (like a todo list)

The idea is when the form is saved… take all the list of “skills” (text) and save it into the bubble database. I have already a datatype called “meetskills”


I need the skills in a database because We will use it for another purpose. I have been watching youtube videos and other tutorials but all the examples are assuming that the custom state list already exist on the database

Another use case that I am thinking about is when the meet is edited, how I would edit the list?

Thanks for your answers

Got it! So, you’ll do the following:

  • Create a backend workflow with two parameters: “skill” (text) and “Meet” (Meet).
  • In the backend workflow, add two actions:
  1. Create a new meetSkill (name = skill)
  2. Make a change to Meet (skills add result of step 1)
  • When the save button is clicked on the page:
  1. Create a new Meet and save all those other details from the form
  2. Schedule the backend workflow on the list of texts (the custom state). The type of data in this action is just “text.” Provide values for the 2 parameters: skill = “this text” and Meet = result of step 1

That’s it! In sum, the page will create the new Meet and trigger the backend to create a new Skill for every text AND link it to the new Meet.

Happy building! :slight_smile:


Cheers, Gaby
Co-Founder at Coaching No Code Apps
Free Bubble Masterclass
Private Help

2 Likes

@romanmg @Trynocode Thanks for your answers

This topic was automatically closed after 70 days. New replies are no longer allowed.