Hi there, @petrybr… as with all things Bubble, I’m sure there are a number of ways to do what you have described, and a way that comes to my mind involves a backend workflow and one additional field (a user list) on your Pair
data type. Oh, and bear with me on this one because, while I think this suggestion is a reasonable one, someone could easily come along and rip it to shreds for some reason that isn’t readily apparent to me. That being said, here’s what I’ve got.
My Pair
data type looks like this…
I have a backend workflow called create pairs
that takes a user list as its only parameter.
I have a button called Create Pairs that calls the backend workflow and sends a user list that is a search for users with no constraints.
The backend workflow has six steps. Step one creates a new thing in the Pair
data type, and it sets the thing’s available users
list to the user list that was passed in to the workflow. It also sets the thing’s User A
to a random user from that user list.
Step two makes changes to the result of step one, and the change it makes is to remove the user that is now the thing’s User A
from the thing’s available users
list.
Step three makes changes to the result of step two, and the change it makes is to set User B
to a random user from step two’s available user
list (which no longer contains the user in User A
).
Step four is the same as step two, except that it makes changes to the result of step three, and the change it makes is to remove the user that is now the thing’s User B
from the thing’s available users
list.
Step five calls the backend workflow again, and it passes in a new user list from the result of step four (which is a list that no longer contains the users in the thing’s User A
and User B
). This step only calls the backend workflow again when a count of the users in the available users
list from step four is greater than 1 (so, the backend workflow will stop running when there aren’t enough users left to make a new pair).
Finally, the last step in the workflow tidies up a bit by clearing the thing’s available users
list because there is no need to keep that list around after the thing has a user in its User A
and User B
fields.
So, there you go… that’s a potential solution that came to my mind. Full disclosure, though… I didn’t actually run that workflow because I created the example in a sandbox on the free plan. Anyway, it’s probably way more than you wanted, but maybe it’s good food for thought… at least until someone comes along and tells us why it’s the worst suggestion ever. 
Best…
Mike