Create a new thing when it does not exist....and make change a thing when it exists

Hello everyone,

I know this topic has been talked many times, I passed many hours on the forum and video to find the solution but i don’t achieve. So today, I need a help.

I try to create a data does not exist but I want to change the data if it exists I read about the warning in 2017 but i still cannot).

So below my workflow to help you to answer me:

In my first screenshot you can see my page. I want to sent the new schedule when the user click on a day (The input is a date/time picker).

Screenshot 2023-12-31 at 07.07.36

The second screeshot is about the first step of the workflow, the make change if it exists.
I tried to action this workflow’s step only when there is a data in the DB Events (Search for Events: counts > 0)

And the last screenshot is about the second step of the workflow, Create a thing if it does not exist.
I tried to action this workflow’s step only when there is NOT data in the DB Events (Search for Events: counts ≤0)

When i do the test in the preview it creates a new data even if the old data already exists. Below the debugger:



Where are my mistakes ?

Thank you by advance

Dates are always problematic when comparing with equality. Sometimes, the seconds, sometimes the minutes of the date might not match to find the existing one. If you paste the existing app data for this table as well, it might help.

Sure, below a screenshot of the Data Type

And the Database
Screenshot 2023-12-31 at 08.06.29

As you can see, the data type of schedule is date
And it knows that it is a date because the new dates are saved. But the “Make change” does not work. I don’t know why

I think I figured out the problem. The conditions you put to the workflow actions are working in the opposite way of what you think.

When the Date/TimePicker A’s value is updated, it executes this workflow event but when it calculates the condition of the Create a new Event, it can’t find anything. Because the Search for Events condition is trying to find an event with the newly selected date, not the old one. That’s why every new date you selected in the Date/TimePicker is creating a new entry in your database. Technically, if you want to keep this structure, you should store the old value of the schedule in somewhere or you shouldn’t do an existing search with schedule date but with the ID of the event.

Okay I found another way to do it, but I think it is not sexy at all and maybe it makes my applications a little bit slower. Can you tell me what you think about it ?

First of all, I created a new field in the data Type Event. The field name is “Event organized”, the field type is “Yes/no” and the default is “yes”.
Screenshot 2023-12-31 at 10.40.47

After that, I created a workflow to make an action in case of the date exists in the DB.
So I did a condition to say :
Ok Bubble, work on this action “only when” if there is “Yes” in the field “Event Organized”
The thing to change is the fist item of the DB Event and you will inject the info from the input Date/time Picker A inside the field Schedule.


Then, i created a second workflow to make an action in case of the dates does not exist in the DB.
So I did a condition to say :
Ok Bubble, work on this action “only when” if the first item’s schedule is empty. In another word, if the DB is empty.
The creation will be for the DB Event and you will inject he info from the input Date/time Picker A inside the field Schedule.
Screenshot 2023-12-31 at 10.36.05

to resume, the workflow to create a line will be actioned when the data is empty and the workflow to change the data won’t work because there is no line there is not a “yes” nowhere. And, when the data will be created, the field “Event organized” will fill by a “yes”.

AND, the workflow to change the data will be actioned when the data and more specifically the field Event Organized is “Yes”. because of the last action worked before.

What do you think of it?
I knoz it is not scalable because what about if there is several events but for the moment there might be only one event and later another.
Two worfliw events are more slower than one workflow event with 2 steps ? But in this case, I don’t achieve.

I should explain why i want it. It is just to send an email automatic for the users to say “an event is organized this date”. so I am open to change the structure of my DB

Sorry for my loooooong message

I dont get the full picture but if your only purpose is to send an email to a user when an event is organized this date, you can list your events in a repeating group and then each cell might have a button to set the current cell’s event as organized and update the date as well. Simply make the creation of the event separate from marking it organized and sending email. As far as I see, you should also make who does these more clear. I think take a pen and design something on paper, then dig into bubble design of it.

You can use the format as operator to manipulate the date or format as simplified ISO to remove those potential issues.

Screen Shot 2024-01-01 at 4.10.51 PM