Random Sorting on Backend Possible?

I’m trying to Do a Search for a list of things, sorted randomly to get a random list of 5 random items that are different in each run of the workflow.

Based on the bubble reference:

Random sorting
Choose this option to randomize the order results. It will be different for each user and after each refresh. It will be the same when re-running a workflow without refreshing the page.

However, since there is no refresh in the backend, this seems to give the same random items each time I run the workflow.

Is there a simple way to get 5 random items of a data type simply on the backend?

I’ve found a workaround but it’s truly terrible:
I can Do a search for thing: random item → this gives me a truly random item each time but only one piece if item from a list and I need 5.
So I created a data fields for “Random Item 1” “Random Item 2” “Random Item 3” “Random Item 4” “Random Item 5” and then I convert them to lists and then I use the merge function to finally get a random list of 5 items.

As you can see this would be even worse if I needed 25 or 50 random items, any better way to accomplish this?

Consider creating a separate backend flow and schedule it as needed (once or on a recurring basis, etc etc). Once it runs set it to schedule the current backend flow that you are building. So, it will act as your trigger.

I don’t really understand your point.
What would you do in the separate workflow?
Get the same one piece of random item each time and then keep scheduling the same workflow until I have the correct amount of items on a given list?
Even that seems like an extremely complicated way to get a random list don’t you think?

Separate was not my point. You are right.

I’m wondering why there’s no more views/answers. Bubble’s inability to do random sorting on the backend is super-frustrating.

5 Likes

Random sorting on the backend still seems to be broken 2 years later. Anyone know how to solve this?

Finally, I was able to enable random sorting of listings in Backend Workflow.
It’s easy to do, just add :make static before doing the random sort.

スクリーンショット 2024-10-01 10.44.05

I am still testing, but it is working fine in my environment.
I hope this helps :wink: