Can someone help me with this problem

in the first screenshot you see a planning form where i filled out the first 3 groups. then i click on save planning and the next screenshots. see how de debugger works. on the last screenshot you see that in the database he only shows, group 2 en group 3, 2 times. in the screenshots about group 3 you can see something different with the “only when” condition.

can someone maybe help me with this problem

Why are you creating a thing and then making changes to it immediately after?

What is your logic for this?

as you can see in the first ss i have the button “planning opslaan” this button saves it for every group. on the same time i want it to check the database if there is al ready an combi of a specific date + group number. and if so then it has to change to the new value’s. i made or try to make it in one button, the save and change option

Are you saying if the group doesn’t exist you want to create it?

And if it does exist you want to change it?

well i try to save a planning from a date, i have 10 different groups. every day il give a group a location and a task. then i save it. when i want to make a change in that plan il change the date to the date i want. and the plan from that date shows. if i need to change a task or location then i want to click again on “planning opslaan” to make the changes, and that with the same button. thats why i have a action. for create and change in one workflow. and that for every group. ….

now i think about it maybe it is an idea that when a combination of the date and group number already exist in the database there appears a button with change the plan so i can get the actions: change and create in a different workflow. but idk if thats the problem here

I think I understand what you’re trying to do…one Save button that either creates a plan or updates one it if it already exists.

The problem is that your “make changes” actions are using ‘search for plannings first item’. So when you save multiple groups, later groups can overwrite earlier ones (that’s why group 1 disappears and group 3 shows twice).

Instead of changing the first item, do this for each group…

search for planning where date= selected date and group number = x…

if that exists make changes to that…

if it doesn’t create a new one.

That way, each group always updates its own record, and you won’t get duplicates or overwrites.

You don’t really need “create then change” back-to-back…just update if found, otherwise create

1 Like

Well i have this for every group (one for creating and one for change) il have an constraint for the date and the time picker but still i dont get it (how do i lose that First planningsitem)

Ok, so based on my professional experience with Bubble…haha, which isn’t actually that much :grinning_face:

I see 2 things wrong with your workflow.

Myself, I would break it into 2 workflows, but that is a personal preference, and I know a lot of others probably wouldn’t.

Anyway, on your make changes to a thing, you just search for first item. You should add company=current company. That will identify the company.

Also, in your things to change, drop the plan_group_number = x. You don’t need to change that if the group was already created

@jortheldens I think what you want to do is just put onto the page a group that contains the ‘plannings’ data type entry and use that ‘is empty’ or ‘is not empty’ to determine if you are creating or editing something that already exists.

In your current setup there is not really an image that shows what the search is, so my assumption is that it is a search based on a unique id of an entry that is already on the page or not, and so you should just use that detail in your dynamic expressions of the workflows.

So, you have group “planning” of data type “planning” that when creating a new “planning” is empty, which signals, “planning” is being created, and when you are editing, it is because planning already exists and from some existing list you pressed an icon or button to say ‘edit this existing planning’ and used a display data action to send that selected existing data entry to the group as its data source so you can show the existing details, which means, the group “planning” entry ‘is not empty’.

No need to run searches in dynamic expressions of the workflow actions.

@senecadatabase suggested possibly having separated workflow series, which is helpful, and in this situation would just mean, you have your one button, with two workflow triggers, one that says ‘when planning planning is empty’ and a second that says ‘when planning planning is not empty’…in the first series are your actions for creating the entries, and in the second, it is for editing the entries.

However, if you expect, as I do, that a user is going to likely come into an existing planning, and want to change only one entry (let’s say entry 5) and leave all 9 others the same, you do not want to run make changes on all 10 (waste of resources), and instead just want to run an action to make changes to just the one…that would mean, to optimize this, you may want to add a button into each of your 10 groups that is only visible when ‘planning planning is not empty’ so that you can target the make changes to just the one group…and you can still keep your existing one button that would read ‘make changes to all’ so that a user could make changes to all 10 at once if they choose to, without a need to press a button for each (ie: press 10 buttons).

There are UX considerations when it comes to optimizing an app and those impact the workflow setup…you do not need to change things if you do not want to in regards to the extra buttons in each group for the individual changes, bubble will only charge for the action (0.6 wus) when it doesn’t actually make any changes (bubble automatically detects no changes required and doesn’t perform), so in theory, if a user were to change only 1 of the 10 and you use just a single button to run the make changes to all 10 in a single series, you will only be wasting (5.4 WUs) per press of button.

3 Likes

Sounds like @boston85719 has some good advice. He’s a lot more experienced at Bubble than I am.

You still will need to add company=current company though, because just searching for the first item won’t do what you want.

Good luck with your project.

I hope you get everything working right

1 Like