How to ALWAYS generate 5 digits in a number (and not sometimes 6 or 4 depenting on 0 )

Hi! Can anyone help me here? I have a “Generate random number” that I always want to contain 5 digits… I have tried with modulo, but sometimes the value gets fewer or more…

image

Hi there, @endrefyl… after playing around with this one to fully understand the problem (I didn’t realize when you convert the 5-character string to a number that the number might not end up being 5 digits), I think there are two possible solutions. One of them appears to be this plugin (I say appears because I have never used it) because you can set a minimum and maximum value for the number…

The other solution (which might come off as a bit hacky) is to use a backend workflow to generate the number and include a final step in the workflow that calls the same workflow again only when the generated number is not between 10,000 and 100,000.

Anyway, maybe someone else will come along with a better suggestion, but I hope this helps, even if it’s just food for thought.

Best…
Mike

Thank you so much for your reply, Mikeloc! I will check this one out :slight_smile: Since my app is starting to get large in size, I try to avoid plugins which are not 100% necessary, so I will try the second one first :slight_smile:

1 Like
  1. Calculate the random string (5 characters lenght) and converted to number
  2. In the same workflow:
    Only when: the calculated number is > 99.999 → change the value for: calculated number / 10 and rounded to 0
    Only when: the calculated number is < 10.000 → change the value for: calculated number * 10 + random string (1 characters lenght) and converted to number

By the way, I understand that the number will be 4 digits long when the first digit is a 0, but when could the generated number be 6 digits long?

1 Like

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