Adding Dates to Database

Hi all,

Been puzzling on this one all day so any help appreciated.

I have a table/Data Type called Targets - inside it has Date & revenue as things. I want the user to be able to select a month i.e. Sept get a list of 30 days enter a target for each day of the month and save this to the DB. I don’t want them to have to click save on each RG line, it should be 1 click save all data i.e.

1st - £1000
2nd £1150

Sounds easy, so I figure I will add it via repeating group and a schedule API on list. But a repeating group needs a data source and the data doesn’t yet exists. How do I create a bunch of new things?

Thanks
Simon

Hi Simon,

You’ll need to trigger an API to create the rows in the table when a user selects a month from the dropdown. You can create rows equal to the number of the month and save a field called month to create these rows. These should then show up in the repeating group where a user can add revenue for each day. To save on single click, write an API to make changes to the list.

Hope this helps,

Cheers,

Anil

Thanks Anil,

When you say trigger an API do you mean an external API to do this. Or do you mean Schedule API on a list? My problem is not being able to create the RG in the first place as I don’t have source data, I think this is a bubble limitation!

Thanks

Simon

Have you tried “creating” your data first then just modifying it? Or use a “custom state” to create a temporary data file then when you are ready to save you can save them all at once? You can research “custom states” in the forum, there are a lot of questions about it. Custom states were a real eye opener for me when I learned lt. I recommend taking a look at that. :slight_smile:

Hi @J805 thanks for the response. Yes I did think of pre-adding it but it’s just not viable as this is a multi-tenanted app and has lots of users and each user could decide to add 1-month or 12-months of targets at any point. So I would need to pre-load for each user at least 12-months every time they sign up which is not practical.

Yes I use custom states for lots of things but can’t quite see how it would help in this case. How would I save them all at once?

Thanks

Simon

So my solution is to add 31 Add thing statements to add the dates when they select the month. This sucks as a solution but can’t see another way to do it?

Maybe if you share your app someone can take a look at it for you to give you suggestions. I started out the same way though. Basically, my first attempt at bubble was “just get it to work” even if it wasn’t the best solution. Now, a year later, i have learned a lot and try to make it a good solution that works for long term. Don’t worry, you will get there eventually and figure something out. You might just need to come back to it later.

Sometimes i wake up in the middle of the night with a solution and have to write it down before i go back to sleep. Haha. It’s the “Ah Ha!” moment where the light bulb goes off in my head. Anyways, hope you can figure out a good solution.

Thanks @J805. Always learning but I think this is a complex problem. My app already has paying customers and is pretty complex (external API’s and lots of functionality).

I think the challenge here is adding large amounts of data into the database that is not user generated. It appears to be a real weakness of Bubble - its hard to get in via file because of CSV limitations and as I have found is hard to get in via generating within the app.

Anyway solved for now but as you say I am sure I will come across a better solution in the future.

Cheers

Simon

Hi Simon,

Apologies for responding late to this. I meant running an API workflow within bubble to create a list of empty rows in the table. Once the rows are created, you can schedule an API on this list of rows. In other words, create rows for the repeating group when a user selects a month, and then run an api on the rg rows to save data in the table.

Hope this is helpful.

Regards,

Anil

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