How to set and change variables (NON-INPUT)

Hello all.

In most programming, I can simply write x=1 and then x equals 1. Or I can say one variable equals another variable by writing Var1 = Var2.

Yet this isn’t so straight forward in Bubble. I understand that this is where states comes into play, yet I can’t figure out how to use them especially when they are NOT based on what a user types into an input.

I am trying to build a decision tree that goes from step to step when the user clicks the next button. Each step has a field for Next Step and this is pre-assigned (not generated by user) number. When the next button is clicked, I want Bubble to lookup the current step’s next step id, reassign the current Step ID = Next Step ID and then display that step’s information. (So the next step becomes the new current step.)

I have tried to do this through workflows for When the Button Next is clicked, but it isnt working. This is what I have so far…

This is maddening! If anyone is open to creating a simple example to show how this might work, it would probably be of great benefit to many others with this same issue. Details are encouraged.

Thanks so much in advance!

Hey, ok check this out:

This is one way to do it, so if you want to take my example to something closer to what you’re trying to achieve, let’s talk through it, but hopefully this will help explain the principle.

Page Title = next_step
Custom state on page element = Step
Custom state type = number

To start us off, I created a condition that sets the state to = 1 when the page is loaded so that the user always starts at 1.

Now, I have 3 simple text elements on the page that are all only visible when the custom state equals 1, 2 or 3.

I’m going for the most straight-forward progression here, so each step is basically +1 of the previous. So, when Next is clicked, we set the state to = the state + 1

You’ll notice when you run this, I added text at the top to display the state, so you can see the value changing too. Now, when you click next, the state’s value changes by +1 and the text elements react accordingly due to the visibility conditions. I added a reset button that changes the state back to 1 so that you can start over.

Now, your use case - the decision tree - means that the next step could be a few different things, right? Like, if I had options A and B for Step 1, answering A takes me to step 2 and answering B takes me to step 3? Something like that? If so, in that case, you’d do something like “when next is clicked and option A is checked > set state to 2”… “when next is clicked and option B is checked > set state to 3”

Does this help at all?


Hi Gaby,

Thanks again for taking the time to reply and share your vast bubble knowledge! Your example is well laid out and is a great lesson in using states for conditionality on the same page with pre-existing text on that page.

In my case, the decision tree has almost 800 steps so I need to use the same page over and over again, and just repopulate it with the new step’s data each time the user advances or goes back a step (or else I would have to create a lot of individual pages). I do this with text fields inside repeating groups and so the repeating groups need to refresh with the data from the new step once the current step id is reset to the new step’s id. The distinction between your example and this case is that these recurring and text boxes I am using are not hidden on the page until needed; the data in them is refreshed.

When I try to tell bubble to change a state where this variable now equals that variable (new step id = next step id), everything turns red.

I’m not sure if this is very clear, so let me know if I can clarify any of this. Thanks again for your help.

Hey Daryl,

Yeah, I imagined your use case is more tree-like and complex. Would you be able to share a public link to your app since you have a specific structure? It sounds like the solution is somewhere in matching data types, but it will be easier to help your specific need if I could see how everything is working together.

Hey Gaby,

The link is and the specific page is “interface”

Please ignore the two white boxes as those are just things I am testing.



When I posted the link above, I followed it and it takes me to the app in preview mode. However, how do I enable you access to the back end so that you can see the design, data, workflow, etc. in the edit mode? Or am I missing how to access it from the preview mode?

I got it from the info you sent - no worries. But it’s the url from when you’re in the editor yourself:

Since I’m only seeing one Next button, does this mean that your steps go in a specific order? If so, there is actually an action that lets you go to the next item in the repeating group from a button click. All you’d really have to do is set the sort order if it’s something other than each step’s place in the database.

Let me know about this first because if not, you definitely want to be using custom states here - and I can help, but I just have some questions about the structure of your DB.

Updating the database in the way you’re attempting would prevent any user other than the current one to experience the steps from the beginning. If step IDs keep getting changed, they’ll be changed for other users as well.

Hi @romanmg Gaby,
After trying a few dozen keywords I finally landed on this topic that seems somewhat relevant to my case scenario. I tried your above mentioned steps and it worked like charm. But how do we replicate similar results in repeating groups? I don’t know what I am trying to achieve would be possible with that or not.

In my project users request for a service (do a booking) from service provider who may accept or reject the request, the data of service providers is available (but hidden) in a repeating group as I don’t want the users to view credentials of the service providers, rather the search is based on ‘Type of service’. What I am struggling with is the workflow where a service provider rejects a request and then the same is assigned to next service provider, so on till the time the request is honored by someone.

This is my first project and being a finance background person you can understand how good I would be in coding, thankfully bubble works on logic hence could come quite a distance.
Will appreciate help on this, thanks in advance.