Storing two columns of data in a state

Hey! Hey!

I may have a slightly advanced question, so I’ll write the question in bullet points and add screenshots.

  1. I have a data type “holidays” which contains a name and a date.
  2. I have a main group on the frontend that contains state, which is a list of holidays
  3. I have two inputs - for name and for date

App: savinginstates | Bubble Editor

How can I store these two values in this state?


I’m not sure I fully understand the question?.. (or the purpose of it)…

But you can create two more custom states (one of type date and one of type text) to store those values.

Although why do you need to store them in custom states if they are already help as values in the inputs (unless you’re clearing the input values - in which case why are you doing that)?

What exactly are you trying to do here?


Maybe it’s better if I describe the user story.

It has to be one state, because I have it as one data type in the database.
The user opens a popup where they can provide their company information and have the option to add holidays (there can be more than one). I keep all the company information (like name, website, etc) on the frontend, and I need to keep the vacations as well, because only when I click the “create” button will these things be created in the database.

right… well a Custom State of type Holiday can only hold actual Holiday entries from the database. So if the entry doesn’t exist yet you can’t use a custom state of Holiday for this.

There are plenty of forum posts about this type of thing that go into more detail, and the truth is that there’s no simple way to do this in Bubble (although it can be done)…

basically you’ll have to create some kind of list of texts to hold the values from the inputs, in a form that they can be related to each other, and then use that list to iterate over to create your new Holiday entries.

Exactly how that list is formatted is up to you - I tend to just make a simple concatenated string, containing some unique identifier (as lists of texts can’t contain duplicate items), and the relevant values, joined with some arbitrary character (or characters - just make sure they won’t be used in the values themselves).

I usually just store those texts in a custom state list of texts, but you could use Session or Local storage depending on your needs.

Then, once your user hits the create button, send that list to a backend workflow and create the Holidays, by :splitting those strings into their component values.

Although it’s a bit more work to set up, using the Bulk Data Create API endpoint is the fastest and most WU efficient way to do this, but if you’re not too worried about WU then use a recursive workflow (or even run the workflow on the list).

Having said that, I’d generally agree with @NigelG that just creating the Holidays in the database as you go is much simpler (you can always delete them later if they’re not needed).

Although with the new WU pricing model, it’s definitely not the most WU efficient way to do things, it is a whole lot easier.

So ultimately you just need to weight up if it’s worth the extra complication to save a few WUs or not.

Yep… that’s one major thing missing that would be very useful to have.

1 Like

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