Create different things in the same flow

Hi guys,
I have a booking create flow where I “create a thing(booking)” . The booking can be hourly or daily (one or more days)

Ultimately, I’m writing to the “bookings” table all these states that I capture beforehand.

However, I want to write the number of days OR the number of hours from this booking into the database IN THE RIGHT place. As you can see, I have states for both, but how can I put the logic when hours->write to hours field and when days->write to the day field in the DB?

You can’t without conditionals. Instead use one field and do math. If hours greater than 24 it’s a day.

How would I do it with conditionals then? That makes the most sense?

Two separate create thing actions with the conditional based on is it adding field value for day or hour.

One field and do the math to calculate how many days if number is greater than 24

Just use 2 variables (group data) with conditional datasources.

var Booked Hours
if booked by hours set as the number of hours
If booked by days, leave empty

var Booked Days
if booked by Days set as the number of Days
if booked by Hours leave empty.

Or, in your case, as you’re using Custom States (it makes it slightly more complicated) just don’t set both custom states - only set the correct one (i.e. Days for Days and Hours for Hours).

Thanks Adam. Very skilled as usual. What do you mean 2 variables (group data)? Where are they in Bubble?

Groups

I already have the day and hour in two different groups on the page before the booking.where would I put all the condiitonals you mentioned (logic)?

Put the conditional data sources on the appropriate groups.

So on the Day group if the booking type is Daily set the data’” source to the number of day, and if it’s Hourly then leave it empty.

Do the opposite for the Hour group.

1 Like

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