Toggle Yes/No based on 'Do a search for' in DB

Hello Bubble Bashers!

I’ve set up a toggle to create a new thing - y/n which is working perfectly.

What I need to find out from you talented individuals is how to set the toggle to y/n based on the DB entry?

Appreciate any assistance as always

Best,

R

Hey there @ryan23,

So you’re asking about how to change your Yes/No field based on another record that might get modified? Correct?

You can probably use the “When ___ is true” workflow for this.

Hi Jonny,

So the user toggles yes and clicks save.

Next time the page is refreshed, toggle should read from the DB entry they’ve just saved and toggle yes.

Tried conditionals on the toggle (when DB entry is yes, value is yes)
Tried setting state on parent group

Neither seem to work

Are you referring to a ‘Toggle’ element? Such as Bubble’s Ionic Toggle?

If so, just set the Preset Status to ‘Dynamic’ then select the database field to read from.

Hi Adam,

It’s a ‘better toggle’ plugin and tried pointing to the DB

In that case you just need to set the ‘Value’ in the Better Toggle plugin properties editor to the database field.

image

I just tested this and it works fine - but one (strange) thing to note: for some reason the Better Toggle element doesn’t update its value in real time (unlike other elements), so if you change the database value some other way (such as from within the Bubble Editor or via a backend workflow) you need to refresh the page before the better toggle element shows the new value.

Thanks Adam,

So not really a “better” toggle as suggested then?

I’ve set the value to the yes/no field but still no joy :confused:

Are you sure you’ve got the required data, and are referring to it it correctly?

Set up a simple test with another toggle, or even just a text element, to make sure the data is being pulled correctly from the database.

If it is then there must be a bug with the plugin (as I said it works fine for me apart from not updating correctly) - so the best thing to do is to test it first.

If it’s not working even with t text element (or any other display element), then check that your data exists, and double check how you’re referencing it on the page.

Sorted it in the end after playing around - thanks for the suggestions.

Set the group around the toggle to ‘do a search for’ and toggle value to parent group’s DB location - it’s the simplest of things sometimes that stops you moving forward! :smiley:

1 Like