Is it possible to have application level global variables

and have it be available as dynamic data?

Any progress on this? I have just such a need myself! Actually, I need more of a ā€œconstantā€, but a global variable would work. Basically, I have a string that wonā€™t change but which needs to be used in various places throughout the app.

Any suggestions?

-Steve

1 Like

Yeah I do this all the time. Either add such data in the data tab or build a little admin interface for it.

Hereā€™s a simple example. Letā€™s say you want an array of things for representing the Days of the Week.

Make a data type ā€œDay of Weekā€ give it fields for Name (a text), index (a number), and anything else u want to reference about those things. Now make 7 of them.

Boom. Now you have a system level object that is a list of Day of Weeks. To access it, Do a search for Day of Weeks. This will return that list, see?

1 Like

Ah yes, of course. Just use the DB.

Still, it would be great to have something like a global ā€œstateā€ that could be inserted via dynamic data instead of having to do a ā€œsearch forā€ and incur the overhead of DB access (although Iā€™m sure Bubble intelligently caches things).

Thanks, @keith

2 Likes

What youā€™re describing would be the same exact thing. Iā€™ve noted in the past that ā€œDo a search forā€¦ā€ / ā€œSearch forā€¦ā€ things is redundant terminology (it should just be labeled ā€œThingā€¦ā€ IMHO).

There is one alternative for system level things that you want to have available immediately in a page. You can put a custom state on the page that defaults to whatever value you want. Of course, you need to include that in any new page you build. (I guess this could be in a reusable as well.)

But thereā€™s not really any significant performance advantage to doing that. And itā€™s hard to maintain.

Also, if the custom state thing in question is a list (array) you wonā€™t be able to set a default that way.

Point is, things have to come from somewhere. That somewhere is a database.

(And yes, if this is a thing you refer to a lot, the ā€œsearchā€ becomes optimized.)

2 Likes

This is a nice idea, and wouldnā€™t affect performance nearly as much as retrieving from the database.

Check out the [New Plugin] 'Env' Environment Variables plugin :smiley: Itsā€™ almost exactly what youā€™re asking for but at page level

Cheers,
Gaurav
Bubble Developer Kit

2 Likes

For anyone who might stumble upon this old thread, Option Sets pretty much addresses this for me. :slightly_smiling_face:

2 Likes

I hate to revive such an old thread, but there are numerous situations where itā€™s better to keep some part of the applicationā€™s state in memory instead of in the primary DB. Itā€™s dramatically faster to access and update.

In particular, if you have some process that needs to run multiple times a second or even every second, you probably donā€™t want to write to the DB every single time! I stumbled on this thread because Iā€™m also looking for a clean way to create application-level state (as opposed to a custom state on a specific visual element on a single page).

@keith
If we create system level object then where does it get stored in a browser or in a bubbleā€™s database?
Also have same question for current user record.
If we are storing data in a current user record whether it will be stored in DB or browser cookies?

@guarav,
Can we use this plugin to store a list of custom variables?

The link is not working, can you edit the link?

No, I canā€™t. The post is too old. Bubble has since revamped the documentation. It now resides here. Just search for ā€œoption setsā€.

1 Like