[Need Help] How to update the value based on another cell

Hi, I am trying to get the database to update the number of guests of an attendee to be zero when the attendee marks themselves not attending. At the moment, if the attendee previously marked themselves as attending and had guests, then when I mark the attendee as not attending, I cannot seem to get the database to update.

I have tried to put in a condition that when the dropdown’s value is “no” (or “No”, neither works), this input’s content is 0, (I ahve tried all sorts of combinations) but that doesn’t seem to work…

image

image

Also, I cannot seem to get the initial content to be zero either. When I put in this conditional, there is still no initial content.

image

image

Is this me, or a bug in the system…?

Hey @StandUp :wave:

I can see the frustration here. Let’s see if we can help you out here. Are you trying to change the database with a condition?

Can you just update the fields on the current user as they are changing it instead?

FYI: Also, your conditions might not work because your ‘Can you attend?’ value seems to be capitalized but your condition seems to be lowercase.

Let me know if that helps. :blush:

1 Like

Hi J805, thanks, yes, I am trying to change the database.

My intention is for this condition to change the number here to zero, and then for the action of pressing the Submit button to cause the database to update.

I have change the capitalisation, but it still doesn’t work.

I am not sure what you mean by change the fields on the current user, but I have tried to change a conditional on the Current User’s Attendance so that when it is No, the Input number of guests value to be zero, but that hasn’t worked either…

image

Also, when I reset the page, it does change the value (number of guests) to zero, just it won’t when I am making the change via the dropdown

Hey @StandUp :wave:

Hmm :thinking:. That’s a tough one. So that condition won’t work because I think it is a circular reference. It is referring to itself in a way.

If your dropdown says no, you are changing the dropdown’s default value. The default value won’t work because you are checking a condition on the input.

Right now it says: ‘Input Number of guest’s value is 0’ which will return either ‘yes’ or ‘no’. Not capitalized.

I think you have the conditions in the wrong place and the conditions are incorrect. Let me try to set up an example for you since it’s hard to explain everything here. It might just confuse you more.

Let me set it up and I will come back and post the links here.

1 Like

Hi there, @StandUp… I’m sure Jason’s got you covered with the example he is going to create, but for what it’s worth, the first screenshot in your first post is on the right track, but it doesn’t work because the initial content of the input is not reevaluated when the dropdown’s value is changed. If you put the input in a group and set the group’s data source to a value (in your case, 0) when a particular option (in your case, the No option) is selected from the dropdown and you set the initial content of the input to the parent group’s data, you would get the desired result. You can also do it by setting a custom state to a value when the dropdown’s value is changed, and set the input’s initial content to the custom state’s value.

Anyway, like I said, I’m sure Jason’s example will show you the way, but that’s what is going on there.

Best…
Mike

2 Likes

Very much appreciated, yes please and thank you!

1 Like

Hi Mike, thank you for your reply. I am a little confused still though…

@StandUp Here is the example for you:

Editor: 805testapp42 | Bubble Editor

Preview: https://805testapp42.bubbleapps.io/version-test/attend_event?debug_mode=true

Is this what you are looking for?

Hi J805, that doesn’t seem to do it - if I set the number of guests to more than 0 (i.e. 9), and then set attending to No, then the number of guests should return to zero…

Ok, this is how I would do it then. Try it now. It was previous only saving it after you pressed the button. Would this work for you? Or I can show a different way if this doesn’t work for what you are looking for.

1 Like

That would work, yes:

  • it changed the numer to zero the moment No is selected, and
  • I cannot change the number of guests when No is selected

'tis Magic - how is it done Mr Blaine?!?

And thank you indeed!

I’m definitely not trying to be a jerk here, but it should be noted that if your form has a way for the user to cancel their selections, @StandUp, canceling will do nothing because the input’s values are being saved to the database when the inputs are changed. If you don’t want that to happen, you would need to do something like what I described. If it doesn’t really matter, you can do what Jason is showing, and the submit button is basically redundant at that point.

2 Likes

Yeah, @mikeloc that’s the other way I was going to show if this wasn’t going to satisfy what they needed. You aren’t being a jerk. :blush: I tried to give the simplest example first, then if it doesn’t work, I would add complexity. Like using states or a parent group like you said. There is always more than one way to do something. :raised_hands: No offense taken here for sure.

2 Likes

Hi Mike, Jason, thanks both for your help in this, really very much appreciated.

Jason, very sorry, I am lost as to get to there through the workflows, I still can’t see what you have done. Yes please to a little more info on what you did.

Mike, I am not sure. If the user tries to update the number of guests and then sets their own attendance to no, I need the database guest number to be set to 0…
I am sorry, but I got lost in your explanation too. It would be amazing if you could give a bit more detail to explain your solution too so that I can learn from it.

Apologies to both that I need the extra explanation! And thanks again. I am getting there, and I most certainly will get there!

1 Like

Here is the workflow that does the magic:

Just right click on your dropdown and choose Start/Edit Workflow:

1 Like

Ah, so I must be doing something wrong again.

I tried to imitate you, but when I reset relevant inputs, it makes the dropdown unuseable,
image

and when I get rid of reset relevant inputs, it makes the change on the page (the total number of guests returns to the correct number),
image
becomes
image

but pressing save causes that number to increase again…
image

Ok, I just modified it a bit by removing the workflow on the submit button. You really don’t need it since the workflows are happening on when the input or dropdown has changed. What is your workflow doing? Maybe a screenshot of the workflow might help, or even better, share your editor. You can send me a direct message so you don’t have to expose it here.

1 Like

So you are still missing a few things here, check it out:

When you do formatted as text, change the yes and no to Yes and No.

You are also missing a workflow on the Number of guests workflow if you want it to save right away too.

Does that help?

1 Like