# Random number generator

It would be great if there was a way to generate a random number instead of having the users rely on making a blockspring account or any other creative way.

I suggest the following implementation:

Is this possible?

You can already do this with Calculate formula > Generate Random String

Gaby | Coaching Bubble

3 Likes

The issue with that method is you canâ€™t put bounds (min, max) on it. It would be possible if you can access the string that it generates as a number, then itâ€™s possible to transform it to fit within a range.

Thanks, but not quite what Iâ€™m after. As your screenshot also shows, itâ€™s generating a string and not an integer/float value. This makes it unusable in stuff asking for number inputs

I tried generating a random string using numbers but thereâ€™s no â€śconvert string to numbersâ€ť (and afaik that is not an easy task as it would have to interpret the string first. Would be a lot easier to just generate an integer/float without going through a string)

If you select â€śUse numbersâ€ť only, the value is a number (not a text string). I just tried it with 2 inputs (integer type) whose initial content is generated and added the values in a text element. It worked.

However, Scott is right that you donâ€™t have any more control beyond number of digits. Canâ€™t define a range or anything. Just spits out random numbersâ€¦

With the observation @romanmg made about inputs typecasting the value from a string to number, itâ€™s possible. The following generates a random number between an arbitrary min and max of 2000 and 2999, respectively.

5 Likes

Thatâ€™s odd that it works that way, during workflow it wonâ€™t see it as an integer.
My custom state named â€śnumberâ€ť is set to type=number

Just reference the group on the page that stores the random value.

1 Like

Thatâ€™s a workaround I am content with using, but my initial suggestion still stands. Thank you @Scott and @romanmg for this so far easiest bubble-only workaround

1 Like

@Scott Any idea how you would change this random number via button press event? I see that weâ€™re generating the number on â€śinitial contentâ€ť when the page loads, but is there a way to get a new random number from a workflow event?

Awesome workaround btw, thanks!

1 Like

We just released a plugin that allows users to generate a random number with a minimum and maximum. Hereâ€™s the original post for it:

1 Like

@romanmg
This is awesome I was looking for a way to create a random string.

Any idea how I would go about using that string so clients could look at a webpage (of a user that has an account) instead of having to go through the login or signup process? Kind of like a read only page and only that user can give out this generated key.

Thanks!

I really need help , my references keep changing every time i refresh the page . How can i really fix this. How can i keep them static .