Forum Academy Marketplace Showcase Pricing Features

Global variables in Bubble?

Hi,

Are global variables supported in Bubble? We need to generate a new userID for each user that signs up. Having a global variable will make it easy to implement simple userID generation mechanisms.

Any pointers on how to achieve this would be appreciated. Thanks.

No, we don’t have this concept yet. How would that help you with your userID?

Bubble generates a user id (actually for each thing) that is unique. it’s a bit long, but if you want to make sure you can identify people safely, you can use this https://bubble.io/reference#Data.Messages.CustomType._id

A global variable would retain state across all users of the web app. If we wanted to generate userIDs from our own state space, then whenever any users hits a page in the app where a new userID needs to be generated, the webapp would query this global variable, generate a userID from it, and update the global variable itself.

I did notice the userID before, but I wasn’t sure if it was safe to use it. I mean, if I expose this ID, would someone be able to query S3 and get access to the object? I’m not sure how it works, but it sounds like it is safe to expose this to users and they cannot use it as a capability to directly access any backend AWS resource?

Thanks.

I omitted to mention that one way of handling this would of course be if we built a web api that provided a userID function, and that API can handle this state. But I’m not sure if we can make our own API yet.

Do you think that the blockspring option you mention in Login through specific API? will handle this approach to solving it?

If you have set up some privacy rules, it’s safe to expose the the id. You’ll have to specific some rules when using a file uploader, so that the content that is uploaded is secure.

Are there any updates on this by chance? I’m needing the same functionality.

In my case, I have an Entry thing that a user can submit, and all users can see all Entries. A user can create a new Entry based off someone else’s entry, and I’d like to be able to keep track of those as “batches”.

The way that I was thinking I could do that was to have a global Batch count, and allow for an Entry to have a Batch field. The functionality would then be:

  1. Each time a new Entry was created from scratch, it updated its Entry -> Batch field to be the current global Batch number
  2. the global Batch number would get incremented
  3. Each time any existing Entry got used to create a new Entry, the new Entry would set its Entry -> Batch field to equal the Entry -> Batch field of the existing Entry it is being based on

This would allow for all Entries to be properly grouped by their Batches.

Is there a way to create a global Batch count? And then use & increment it in the app by different users? And if not, is there any other way to set up the type of grouping I need?

Thank you!

Yes, not complex at all. I have one in action here (it is a simple counter of a scheduled API workflow, so properly “background” but don’t tell emmanuel I haven’t worked out how to switch it off yet :slight_smile: ).

The workflow just updates a number on a thing each time. There is only 1 thing, and it gets the first one.

And this is all there is on the data type.

4 Likes

Thank you!!