Generate semi-random string and check output against existing data?

I have setup a simple string generator, which takes 2 random strings from a set of strings in the database and appends them together.

Before displaying it on the UI, I want to check it against existing data in the database to make sure this newly generated string isn’t already used.

I am only able to generate the string by using the display data in element action. I’ve been thinking about created a temporary database object, but that seems like it’s going to slow down things a lot. The string generator is already disappointingly slow.

How can I achieve this?

Have you tried to store it in a custom state instead of the database?

No I haven’t! That’s an interesting idea, but can I do that from a backend workflow?

Unfortunately, no

So after a lot of trial and error I have found the best approach is the following:

  1. I generate a lot of strings in database, and every now and then run a workflow that will increase string population if it is below a threshold.

  2. Create an invisible group with a default value 1 and when clicking on the button intending to refresh the random string, increase that value of +1 or set it back to 1 if that value is >= total strings available.

  3. Load all strings on the front-end and sort them randomly, and selecting item n# N where N is the current value of the group above.

Here is a sample:
Game Lobby #HLUH9M (3)

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