Generate random string not consistent (no joke)

Not sure if this is a bug or expected behaviour. I can’t find any useful documentation for how the function is supposed to work.

The issue I’m seeing is that generating a random string of 4 digits, will sometime generate a string of 3 digits. I need to consistently generate pin codes consisting of 4 digits.

Has anyone been having this issue or know more about how the length of characters is supposed to work?

Are you saving it as a text or a number?

Saving it as a number might end up doing a lower number possibly.

If the random number is 0987 and it’s saved as a number it will actually save 987.

Does that make sense?

Oh is that what’s going on. I suspected it was perhaps ditching 0’s at the start of a string. I’ll try saving it as a text and see what happens. Thanks!

Edit: that was probably it. saving it as text retains the 0’s at the start of a string. So far I haven’t seen any <4 digit strings being generated.

1 Like

This topic was automatically closed after 14 days. New replies are no longer allowed.